Fixed several issues and made some enhancement to make it more robust. now pushing to both gitea server and github.

This commit is contained in:
ameer
2026-02-16 22:33:08 +08:00
parent 17289aeac4
commit f4b6098eb2
7 changed files with 176 additions and 57 deletions

View File

@@ -8,10 +8,16 @@ set -e
echo "Configuring Chinese mirrors (Aliyun) for apt, pip, and npm..."
# Replace Ubuntu sources with Aliyun mirror
# Ubuntu 24.04+ uses DEB822 format in sources.list.d/ubuntu.sources
if [[ -f /etc/apt/sources.list.d/ubuntu.sources ]]; then
sudo sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list.d/ubuntu.sources
sudo sed -i 's|http://security.ubuntu.com/ubuntu/|https://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list.d/ubuntu.sources
echo "Updated Ubuntu apt sources to use Aliyun mirrors"
echo "Updated Ubuntu apt sources (DEB822 format) to use Aliyun mirrors"
# Ubuntu 22.04 and older use the traditional sources.list format
elif [[ -f /etc/apt/sources.list ]]; then
sudo sed -i 's|http://archive.ubuntu.com/ubuntu|https://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
sudo sed -i 's|http://security.ubuntu.com/ubuntu|https://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
echo "Updated Ubuntu apt sources (sources.list format) to use Aliyun mirrors"
fi
# Configure npm registry to use Chinese mirror (npmmirror.com is the recommended mirror)

View File

@@ -3,14 +3,19 @@
# Setup home directory for the current user
# Useful for attaching vscode with container
set -e
user_name=$(whoami)
user_home="/home/$user_name"
# Root's home is /root, not /home/root
if [[ "$user_name" == "root" ]]; then
user_home="/root"
else
user_home="/home/$user_name"
fi
echo "Setting up home directory for user: $user_name"
sudo mkdir -p "$user_home"
sudo chown -R "$(id -u):$(id -g)" "$user_home"
cp -r /etc/skel/. "$user_home" 2>/dev/null || true
# Use -n (no-clobber) to avoid overwriting existing dotfiles (e.g. from mounted volumes)
cp -rn /etc/skel/. "$user_home" 2>/dev/null || true
echo "Home directory setup completed: $user_home"

View File

@@ -36,7 +36,7 @@ term_handler() {
# Kill any still-running background processes if they didn't shut down gracefully
if [[ -n "$INIT_PID" ]]; then
if kill -0 "$INIT_PID" 2>/dev/null; then
echo "Init process still running, force killing: $INIT_PID"
echo "Init process still running, sending SIGTERM: $INIT_PID"
kill "$INIT_PID" 2>/dev/null
else
echo "Init process already terminated gracefully"
@@ -49,9 +49,11 @@ term_handler() {
kill "$TAIL_PID" 2>/dev/null
fi
# Stop SSH service
echo "Stopping SSH service..."
sudo service ssh stop 2>/dev/null || true
# Stop SSH service if it was started
if [[ "${ENABLE_SSH:-true}" == "true" || "$ENABLE_SSH" == "1" ]]; then
echo "Stopping SSH service..."
sudo service ssh stop 2>/dev/null || true
fi
echo "Cleanup completed, exiting..."
exit 0
@@ -75,8 +77,13 @@ if [[ $LOG_FILE != "/dev/null" ]]; then
sudo chown -R "$(id -u):$(id -g)" "$LOG_FILE"
fi
echo "Starting SSH service..."
sudo service ssh start
# Start SSH service unless explicitly disabled
if [[ "${ENABLE_SSH:-true}" == "true" || "$ENABLE_SSH" == "1" ]]; then
echo "Starting SSH service..."
sudo service ssh start
else
echo "SSH service disabled (ENABLE_SSH=$ENABLE_SSH)"
fi
# Run initialization commands (last one in background to allow signal handling)
# First collect all defined COMMAND_INIT variables