update base scripts

This commit is contained in:
skywalker 2024-08-22 18:14:42 +08:00
parent 48c01d9b33
commit ed9d0d0833
8 changed files with 97 additions and 9 deletions

View file

@ -22,7 +22,7 @@ LOG_LEVEL_WARN = 1
LOG_LEVEL_INFO = 2
LOG_LEVEL_DEBUG = 3
SHENV_NAME_WHITELIST_REGEX = re.compile('\W')
SHENV_NAME_WHITELIST_REGEX = re.compile(r'\W')
log_level = None
@ -93,7 +93,7 @@ def import_envvars(clear_existing_environment=True, override_existing_environmen
# Text files often end with a trailing newline, which we
# don't want to include in the env variable value. See
# https://github.com/phusion/baseimage-docker/pull/49
value = re.sub('\n\Z', '', f.read())
value = re.sub('\n\\Z', '', f.read())
new_env[name] = value
if clear_existing_environment:
os.environ.clear()

View file

@ -11,9 +11,12 @@ mkdir -p /etc/container_environment
echo -n no > /etc/container_environment/INITRD
## Enable Ubuntu Universe, Multiverse, and deb-src for main.
sed -i 's/^#\s*\(deb.*main restricted\)$/\1/g' /etc/apt/sources.list
sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
sed -i 's/^#\s*\(deb.*multiverse\)$/\1/g' /etc/apt/sources.list
if grep -E '^ID=' /etc/os-release | grep -q ubuntu; then
sed -i 's/^#\s*\(deb.*main restricted\)$/\1/g' /etc/apt/sources.list
sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
sed -i 's/^#\s*\(deb.*multiverse\)$/\1/g' /etc/apt/sources.list
fi
apt-get update
## Fix some issues with APT packages.

View file

@ -17,3 +17,4 @@ rm -f /etc/cron.daily/upstart
rm -f /etc/cron.daily/dpkg
rm -f /etc/cron.daily/password
rm -f /etc/cron.weekly/fstrim
rm -f /etc/cron.d/e2scrub_all

View file

@ -0,0 +1,83 @@
#
# Copyright 2023 Balazs Scheidler
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The regular expressions were extracted from
# https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions
# and converted into a TSV format by Balazs Scheidler.
#
# List of tab separated fields
#
# comma-separated-states /regexp/ new_state
#
# java
start_state,java_start_exception /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/ java_after_exception
java_after_exception /^[\t ]*nested exception is:[\t ]*/ java_start_exception
java_after_exception /^[\r\n]*$/ java_after_exception
java_after_exception,java /^[\t ]+(?:eval )?at / java
java_after_exception,java /^[\t ]+--- End of inner exception stack trace ---$/ java
java_after_exception,java /^--- End of stack trace from previous location where exception was thrown ---$/ java
java_after_exception,java /^[\t ]*(?:Caused by|Suppressed):/ java_after_exception
java_after_exception,java /^[\t ]*... \d+ (?:more|common frames omitted)/ java
# python
start_state /^Traceback \(most recent call last\):$/ python
python /^[\t ]*File / python_code
python_code /[^\t ]/ python
python /^(?:[^\s.():]+\.)*[^\s.():]+:/ start_state
# PHP
start_state /(?:PHP\ (?:Notice|Parse\ error|Fatal\ error|Warning):)|(?:exception\ '[^']+'\ with\ message\ ')/ php_stack_begin
php_stack_begin /^Stack trace:/ php_stack_frames
php_stack_frames /^#\d/ php_stack_frames
php_stack_frames /^\s+thrown in / start_state
# Go
start_state /\bpanic: / go_after_panic
start_state /http: panic serving/ go_goroutine
go_after_panic,go_after_signal,go_frame_1 /^$/ go_goroutine
go_after_panic /^\[signal / go_after_signal
go_goroutine /^goroutine \d+ \[[^\]]+\]:$/ go_frame_1
go_frame_1 /^(?:[^\s.:]+\.)*[^\s.():]+\(|^created by / go_frame_2
go_frame_2 /^\s/ go_frame_1
# Ruby
start_state /Error \(.*\):$/ ruby_before_rails_trace
ruby_before_rails_trace /^ $/ ruby
ruby_before_rails_trace /^[\t ]+.*?\.rb:\d+:in `/ ruby
ruby /^[\t ]+.*?\.rb:\d+:in `/ ruby
# Dart
start_state /^Unhandled exception:$/ dart_exc
dart_exc /^(Instance of)|(Exception)|(Bad state)|(IntegerDivisionByZeroException)|(Invalid argument)|(RangeError)|(Assertion failed)|(Cannot instantiate)|(Reading static variable)|(UnimplementedError)|(Unsupported operation)|(Concurrent modification)|(Out of Memory)|(Stack Overflow)/ dart_stack
dart_exc /^'.+?':.+?$/ dart_type_err_1
dart_type_err_1 /^#\d+\s+.+?\(.+?\)$/ dart_stack
dart_type_err_1 /^.+?$/ dart_type_err_2
dart_type_err_2 /^.*?\^.*?$/ dart_type_err_3
dart_type_err_3 /^$/ dart_type_err_4
dart_type_err_4 /^$/ dart_stack
dart_exc /^FormatException/ dart_format_err_1
dart_format_err_1 /^#\d+\s+.+?\(.+?\)$/ dart_stack
dart_format_err_1 /^./ dart_format_err_2
dart_format_err_2 /^.*?\^/ dart_format_err_3
dart_format_err_3 /^$/ dart_stack
dart_exc /^NoSuchMethodError:/ dart_method_err_1
dart_method_err_1 /^Receiver:/ dart_method_err_2
dart_method_err_2 /^Tried calling:/ dart_method_err_3
dart_method_err_3 /^Found:/ dart_stack
dart_method_err_3 /^#\d+\s+.+?\(.+?\)$/ dart_stack
dart_stack /^#\d+\s+.+?\(.+?\)$/ dart_stack
dart_stack /^<asynchronous suspension>$/ dart_stack

View file

@ -1,4 +1,4 @@
@version: 3.35
@version: 4.3
@include "scl.conf"
# Syslog-ng configuration file, compatible with default Debian syslogd
@ -7,7 +7,7 @@
# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
dns_cache(no); owner("root"); group("adm"); perm(0640);
stats_freq(0); bad_hostname("^gconfd$");
stats(freq(0)); bad_hostname("^gconfd$");
};
########################

View file

@ -9,6 +9,7 @@ SYSLOG_NG_BUILD_PATH=/bd_build/services/syslog-ng
$minimal_apt_get_install syslog-ng-core
cp $SYSLOG_NG_BUILD_PATH/syslog-ng.init /etc/my_init.d/10_syslog-ng.init
cp $SYSLOG_NG_BUILD_PATH/syslog-ng.shutdown /etc/my_init.post_shutdown.d/10_syslog-ng.shutdown
cp $SYSLOG_NG_BUILD_PATH/smart-multi-line.fsm /usr/share/syslog-ng/smart-multi-line.fsm
mkdir -p /var/lib/syslog-ng
cp $SYSLOG_NG_BUILD_PATH/syslog_ng_default /etc/default/syslog-ng
touch /var/log/syslog

View file

@ -25,7 +25,7 @@ $minimal_apt_get_install runit
[ "$DISABLE_SYSLOG" -eq 0 ] && /bd_build/services/syslog-ng/syslog-ng.sh || true
## Install the SSH server.
# [ "$DISABLE_SSH" -eq 0 ] && /bd_build/services/sshd/sshd.sh || true
[ "$DISABLE_SSH" -eq 0 ] && /bd_build/services/sshd/sshd.sh || true
## Install cron daemon.
[ "$DISABLE_CRON" -eq 0 ] && /bd_build/services/cron/cron.sh || true

View file

@ -101,7 +101,7 @@ def fix_media_symlinks():
dst_custom_dir = join(dst_media_dir, 'custom')
if not islink(avatars_dir):
logger.info('The container was recreated, start fix the media symlinks')
call('mv -n %s/* %s' % (avatars_dir, dst_avatars_dir))
call('mv -n %s/* %s' % (avatars_dir, dst_avatars_dir), check_call=False)
call('rm -rf %s' % avatars_dir)
call('ln -sf %s %s' % (dst_avatars_dir, avatars_dir))
call('rm -rf %s' % custom_dir)