aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-02-13 11:14:10 +0800
committerYuqian Yang <crupest@crupest.life>2025-02-20 23:07:54 +0800
commit783c534feffe442c063d5a2410081e31c09e9eb8 (patch)
treedc2e13f182322d6e787ecb060bf9672b10e41b45
parente870972428794f51912dfa955c6de0d712c74db1 (diff)
downloadcrupest-783c534feffe442c063d5a2410081e31c09e9eb8.tar.gz
crupest-783c534feffe442c063d5a2410081e31c09e9eb8.tar.bz2
crupest-783c534feffe442c063d5a2410081e31c09e9eb8.zip
feat(debian-dev): trim it.
-rw-r--r--docker/debian-dev/Dockerfile18
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/11/add-deb-src.bash14
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/11/get-domain.bash5
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/11/replace-domain.bash7
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/11/replace-http.bash7
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/12/add-deb-src.bash22
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/12/get-domain.bash6
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/12/replace-domain.bash7
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/12/replace-http.bash7
-rw-r--r--docker/debian-dev/bootstrap/apt-source/china-source.txt1
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/install-apt-https.bash8
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/setup.bash34
-rw-r--r--docker/debian-dev/bootstrap/bash/bash-completion.bash4
-rw-r--r--docker/debian-dev/bootstrap/bash/code-server.bash2
-rw-r--r--docker/debian-dev/bootstrap/bash/dquilt.bash4
-rw-r--r--docker/debian-dev/bootstrap/func.bash19
-rwxr-xr-xdocker/debian-dev/bootstrap/get-debian-version.bash13
-rw-r--r--docker/debian-dev/bootstrap/home-dot/devscripts1
-rw-r--r--docker/debian-dev/bootstrap/home/.bashrc117
-rw-r--r--docker/debian-dev/bootstrap/home/.quiltrc-dpkg (renamed from docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg)0
-rw-r--r--docker/debian-dev/bootstrap/official.sources23
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-apt.bash41
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-base.bash25
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-code-server.bash28
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-dev.bash18
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-user.bash20
-rwxr-xr-xdocker/debian-dev/bootstrap/setup.bash58
-rwxr-xr-xdocker/debian-dev/bootstrap/start/code-server.bash18
-rwxr-xr-xdocker/debian-dev/bootstrap/wait.bash5
29 files changed, 234 insertions, 298 deletions
diff --git a/docker/debian-dev/Dockerfile b/docker/debian-dev/Dockerfile
index 95f0602..0629e37 100644
--- a/docker/debian-dev/Dockerfile
+++ b/docker/debian-dev/Dockerfile
@@ -2,20 +2,24 @@ FROM debian:latest
ARG USER=crupest
ARG IN_CHINA=
-ARG CODE_SERVER=true
ENV CRUPEST_DEBIAN_DEV_USER=${USER}
ENV CRUPEST_DEBIAN_DEV_IN_CHINA=${IN_CHINA}
-ENV CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER=${CODE_SERVER}
ADD bootstrap /bootstrap
-
RUN /bootstrap/setup.bash
-ENV LANG=en_US.utf8
+ENV LANG=en_US.utf8
USER ${USER}
WORKDIR /home/${USER}
-EXPOSE 8080
-VOLUME [ "/data", "/home/${USER}" ]
-CMD [ "bash", "-l" ]
+RUN --mount=type=secret,id=code-server-password,required=true,env=CRUPEST_CODE_SERVER_PASSWORD \
+ mkdir -p ${HOME}/.config/code-server && \
+ echo -e "auth: password\nhashed-password: " >> ${HOME}/.config/code-server/config.yaml && \
+ echo -n "$CRUPEST_CODE_SERVER_PASSWORD" | argon2 $(shuf -i 10000000-99999999 -n 1 --random-source /dev/urandom) -e >> ${HOME}/.config/code-server/config.yaml
+
+EXPOSE 4567
+VOLUME [ "/home/${USER}" ]
+
+ENTRYPOINT ["tini", "--"]
+CMD [ "/usr/bin/code-server", "--bind-addr", "0.0.0.0:4567" ]
diff --git a/docker/debian-dev/bootstrap/apt-source/11/add-deb-src.bash b/docker/debian-dev/bootstrap/apt-source/11/add-deb-src.bash
deleted file mode 100755
index e134a00..0000000
--- a/docker/debian-dev/bootstrap/apt-source/11/add-deb-src.bash
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-dir=$(dirname "$0")
-domain=$("$dir/get-domain.bash")
-
-cat <<EOF >> /etc/apt/sources.list
-
-deb-src https://$domain/debian/ bullseye main
-deb-src https://$domain/debian-security/ bullseye-security main
-deb-src https://$domain/debian-updates/ bullseye-updates main
-
-EOF
diff --git a/docker/debian-dev/bootstrap/apt-source/11/get-domain.bash b/docker/debian-dev/bootstrap/apt-source/11/get-domain.bash
deleted file mode 100755
index d44ea65..0000000
--- a/docker/debian-dev/bootstrap/apt-source/11/get-domain.bash
+++ /dev/null
@@ -1,5 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-sed "s|.*https\?://\([-_.a-zA-Z0-9]\+\)/.*|\\1|;q" /etc/apt/sources.list
diff --git a/docker/debian-dev/bootstrap/apt-source/11/replace-domain.bash b/docker/debian-dev/bootstrap/apt-source/11/replace-domain.bash
deleted file mode 100755
index 86e88dc..0000000
--- a/docker/debian-dev/bootstrap/apt-source/11/replace-domain.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Backup /etc/apt/sources.list to /etc/apt/sources.list.bak."
-echo "Replace source domain in /etc/apt/sources.list to $1."
-sed -i.bak "s|\(https\?://\)[-_.a-zA-Z0-9]\+/|\\1$1/|" /etc/apt/sources.list
diff --git a/docker/debian-dev/bootstrap/apt-source/11/replace-http.bash b/docker/debian-dev/bootstrap/apt-source/11/replace-http.bash
deleted file mode 100755
index fae082a..0000000
--- a/docker/debian-dev/bootstrap/apt-source/11/replace-http.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Backup /etc/apt/sources.list to /etc/apt/sources.list.bak."
-echo "Replace http to https in /etc/apt/sources.list."
-sed -i.bak 's/https\?/https/' /etc/apt/sources.list
diff --git a/docker/debian-dev/bootstrap/apt-source/12/add-deb-src.bash b/docker/debian-dev/bootstrap/apt-source/12/add-deb-src.bash
deleted file mode 100755
index cf741d6..0000000
--- a/docker/debian-dev/bootstrap/apt-source/12/add-deb-src.bash
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-dir=$(dirname "$0")
-domain=$("$dir/get-domain.bash")
-
-cat <<EOF >> /etc/apt/sources.list.d/debian.sources
-
-Types: deb-src
-URIs: https://$domain/debian
-Suites: bookworm bookworm-updates
-Components: main
-Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
-
-Types: deb-src
-URIs: https://$domain/debian-security
-Suites: bookworm-security
-Components: main
-Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
-
-EOF \ No newline at end of file
diff --git a/docker/debian-dev/bootstrap/apt-source/12/get-domain.bash b/docker/debian-dev/bootstrap/apt-source/12/get-domain.bash
deleted file mode 100755
index a24538c..0000000
--- a/docker/debian-dev/bootstrap/apt-source/12/get-domain.bash
+++ /dev/null
@@ -1,6 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-grep -e 'URIs:' /etc/apt/sources.list.d/debian.sources | \
- sed -E 's|URIs:\s*https?://([-_.a-zA-Z0-9]+)/.*|\1|;q'
diff --git a/docker/debian-dev/bootstrap/apt-source/12/replace-domain.bash b/docker/debian-dev/bootstrap/apt-source/12/replace-domain.bash
deleted file mode 100755
index d55307c..0000000
--- a/docker/debian-dev/bootstrap/apt-source/12/replace-domain.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Backup /etc/apt/sources.list.d/debian.sources to /etc/apt/sources.list.d/debian.sources.bak."
-echo "Replace source domain in /etc/apt/sources.list.d/debian.sources to $1."
-sed -i.bak -E "s|(URIs:\\s*https?://)[-_.a-zA-Z0-9]+(/.*)|\\1$1\\2|" /etc/apt/sources.list.d/debian.sources
diff --git a/docker/debian-dev/bootstrap/apt-source/12/replace-http.bash b/docker/debian-dev/bootstrap/apt-source/12/replace-http.bash
deleted file mode 100755
index ed4391d..0000000
--- a/docker/debian-dev/bootstrap/apt-source/12/replace-http.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Backup /etc/apt/sources.list to /etc/apt/sources.list.d/debian.sources.bak."
-echo "Replace http to https in /etc/apt/sources.list.d/debian.sources."
-sed -i.bak -E "s|(URIs:\\s*)https?(://[-_.a-zA-Z0-9]+/.*)|\\1https\\2|" /etc/apt/sources.list.d/debian.sources
diff --git a/docker/debian-dev/bootstrap/apt-source/china-source.txt b/docker/debian-dev/bootstrap/apt-source/china-source.txt
deleted file mode 100644
index 4312686..0000000
--- a/docker/debian-dev/bootstrap/apt-source/china-source.txt
+++ /dev/null
@@ -1 +0,0 @@
-mirrors.tuna.tsinghua.edu.cn \ No newline at end of file
diff --git a/docker/debian-dev/bootstrap/apt-source/install-apt-https.bash b/docker/debian-dev/bootstrap/apt-source/install-apt-https.bash
deleted file mode 100755
index 70fb371..0000000
--- a/docker/debian-dev/bootstrap/apt-source/install-apt-https.bash
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Install apt https transport."
-apt-get update
-apt-get install -y apt-utils
-apt-get install -y apt-transport-https ca-certificates
diff --git a/docker/debian-dev/bootstrap/apt-source/setup.bash b/docker/debian-dev/bootstrap/apt-source/setup.bash
deleted file mode 100755
index cdf68af..0000000
--- a/docker/debian-dev/bootstrap/apt-source/setup.bash
+++ /dev/null
@@ -1,34 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-dir=/bootstrap/apt-source
-
-echo "Getting debian version..."
-debian_version=$("$dir/../get-debian-version.bash")
-
-if [[ -z $debian_version ]]; then
- echo "Debian version not found."
- exit 1
-else
- echo "Debian version: $debian_version"
-fi
-
-if [[ $debian_version -ge 12 ]]; then
- setup_dir=$dir/12
-else
- setup_dir=$dir/11
-fi
-
-echo "Setting up apt source..."
-
-if [[ -n $CRUPEST_DEBIAN_DEV_IN_CHINA ]]; then
- echo "In China, using China source..."
- "$setup_dir/replace-domain.bash" "$(cat "$dir/china-source.txt")"
-fi
-
-"$dir/install-apt-https.bash"
-"$setup_dir/replace-http.bash"
-"$setup_dir/add-deb-src.bash"
-
-echo "Setting up apt source done."
diff --git a/docker/debian-dev/bootstrap/bash/bash-completion.bash b/docker/debian-dev/bootstrap/bash/bash-completion.bash
deleted file mode 100644
index 75f8333..0000000
--- a/docker/debian-dev/bootstrap/bash/bash-completion.bash
+++ /dev/null
@@ -1,4 +0,0 @@
-if [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
-fi
-
diff --git a/docker/debian-dev/bootstrap/bash/code-server.bash b/docker/debian-dev/bootstrap/bash/code-server.bash
deleted file mode 100644
index 255c280..0000000
--- a/docker/debian-dev/bootstrap/bash/code-server.bash
+++ /dev/null
@@ -1,2 +0,0 @@
-mkdir -p ~/.local/share/code-server
-/bootstrap/start/code-server.bash > ~/.local/share/code-server/log 2> ~/.local/share/code-server/error &
diff --git a/docker/debian-dev/bootstrap/bash/dquilt.bash b/docker/debian-dev/bootstrap/bash/dquilt.bash
deleted file mode 100644
index 96a4eb2..0000000
--- a/docker/debian-dev/bootstrap/bash/dquilt.bash
+++ /dev/null
@@ -1,4 +0,0 @@
-alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg"
-. /usr/share/bash-completion/completions/quilt
-complete -F _quilt_completion $_quilt_complete_opt dquilt
-
diff --git a/docker/debian-dev/bootstrap/func.bash b/docker/debian-dev/bootstrap/func.bash
deleted file mode 100644
index 7782035..0000000
--- a/docker/debian-dev/bootstrap/func.bash
+++ /dev/null
@@ -1,19 +0,0 @@
-is_true() {
- if [[ "$1" =~ 1|on|true ]]; then
- return 0
- else
- return 1
- fi
-}
-
-append-bash-profile() {
- cat "/bootstrap/bash/$1" >> /home/$CRUPEST_DEBIAN_DEV_USER/.bash_profile
-}
-
-append-bashrc() {
- cat "/bootstrap/bash/$1" >> /home/$CRUPEST_DEBIAN_DEV_USER/.bashrc
-}
-
-copy-home-dot-file() {
- cp "/bootstrap/home-dot/$1" "/home/$CRUPEST_DEBIAN_DEV_USER/.$1"
-}
diff --git a/docker/debian-dev/bootstrap/get-debian-version.bash b/docker/debian-dev/bootstrap/get-debian-version.bash
deleted file mode 100755
index 2cc10b9..0000000
--- a/docker/debian-dev/bootstrap/get-debian-version.bash
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-if [ -f /etc/os-release ]; then
- . /etc/os-release
- if [ "$ID" = "debian" ]; then
- echo "$VERSION_ID"
- exit 0
- fi
-fi
-
-exit 1
diff --git a/docker/debian-dev/bootstrap/home-dot/devscripts b/docker/debian-dev/bootstrap/home-dot/devscripts
deleted file mode 100644
index a15b041..0000000
--- a/docker/debian-dev/bootstrap/home-dot/devscripts
+++ /dev/null
@@ -1 +0,0 @@
-export DGET_VERIFY=no \ No newline at end of file
diff --git a/docker/debian-dev/bootstrap/home/.bashrc b/docker/debian-dev/bootstrap/home/.bashrc
new file mode 100644
index 0000000..3646ee2
--- /dev/null
+++ b/docker/debian-dev/bootstrap/home/.bashrc
@@ -0,0 +1,117 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ #alias grep='grep --color=auto'
+ #alias fgrep='fgrep --color=auto'
+ #alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+#alias ll='ls -l'
+#alias la='ls -A'
+#alias l='ls -CF'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+
+alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg"
+. /usr/share/bash-completion/completions/quilt
+complete -F _quilt_completion $_quilt_complete_opt dquilt
diff --git a/docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg b/docker/debian-dev/bootstrap/home/.quiltrc-dpkg
index e8fc3c5..e8fc3c5 100644
--- a/docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg
+++ b/docker/debian-dev/bootstrap/home/.quiltrc-dpkg
diff --git a/docker/debian-dev/bootstrap/official.sources b/docker/debian-dev/bootstrap/official.sources
new file mode 100644
index 0000000..c9aa9a0
--- /dev/null
+++ b/docker/debian-dev/bootstrap/official.sources
@@ -0,0 +1,23 @@
+Types: deb
+URIs: http://deb.debian.org/debian
+Suites: bookworm bookworm-updates bookworm-backports
+Components: main contrib non-free non-free-firmware
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+Types: deb-src
+URIs: http://deb.debian.org/debian
+Suites: bookworm bookworm-updates bookworm-backports
+Components: main contrib non-free non-free-firmware
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+Types: deb
+URIs: http://deb.debian.org/debian-security
+Suites: bookworm-security
+Components: main contrib non-free non-free-firmware
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+Types: deb-src
+URIs: http://deb.debian.org/debian-security
+Suites: bookworm-security
+Components: main contrib non-free non-free-firmware
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
diff --git a/docker/debian-dev/bootstrap/setup-apt.bash b/docker/debian-dev/bootstrap/setup-apt.bash
new file mode 100755
index 0000000..38cba05
--- /dev/null
+++ b/docker/debian-dev/bootstrap/setup-apt.bash
@@ -0,0 +1,41 @@
+#! /usr/bin/env bash
+# shellcheck disable=1090,1091
+
+set -e
+
+if [[ $EUID -ne 0 ]]; then
+ die "This script must be run as root."
+fi
+
+script_dir=$(dirname "$0")
+
+old_one="/etc/apt/sources.list"
+new_one="/etc/apt/sources.list.d/debian.sources"
+
+echo "Setup apt sources ..."
+
+echo "Backup old ones to .bak ..."
+if [[ -f "$old_one" ]]; then
+ mv "$old_one" "$old_one.bak"
+fi
+
+if [[ -f "$new_one" ]]; then
+ mv "$new_one" "$new_one.bak"
+fi
+
+echo "Copy the new one ..."
+cp "$script_dir/official.sources" "$new_one"
+
+if [[ -n "$CRUPEST_DEBIAN_DEV_IN_CHINA" ]]; then
+ echo "Replace with China mirror ..."
+ china_mirror="mirrors.ustc.edu.cn"
+ sed -i "s|deb.debian.org|${china_mirror}|" "$new_one"
+fi
+
+echo "Try to use https ..."
+apt-get update
+apt-get install -y apt-transport-https ca-certificates
+
+sed -i 's|http://|https://|' "$new_one"
+
+echo "APT source setup done!"
diff --git a/docker/debian-dev/bootstrap/setup-base.bash b/docker/debian-dev/bootstrap/setup-base.bash
deleted file mode 100755
index 31ded36..0000000
--- a/docker/debian-dev/bootstrap/setup-base.bash
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-. /bootstrap/func.bash
-
-echo "Setting up basic system function..."
-
-echo "Installing basic packages..."
-apt-get install -y apt-utils
-apt-get install -y locales procps vim less man bash-completion software-properties-common rsync curl wget
-echo "Installing basic packages done."
-
-echo "Setting up locale..."
-localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
-echo "Setting up locale done."
-
-echo "Creating data dir..."
-mkdir -p /data
-chown $CRUPEST_DEBIAN_DEV_USER:$CRUPEST_DEBIAN_DEV_USER /data
-echo "Creating data dir done."
-
-append-bashrc bash-completion.bash
-
-echo "Setting up basic system function done."
diff --git a/docker/debian-dev/bootstrap/setup-code-server.bash b/docker/debian-dev/bootstrap/setup-code-server.bash
deleted file mode 100755
index 34c9697..0000000
--- a/docker/debian-dev/bootstrap/setup-code-server.bash
+++ /dev/null
@@ -1,28 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-. /bootstrap/func.bash
-
-echo "Setting up code server..."
-
-echo "Get latest version of code-server..."
-VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
-echo "Current latest version of code-server is $VERSION"
-
-echo "Downloading code-server..."
-url="https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb"
-curl -sSfOL "$url"
-echo "Downloading code-server done."
-
-echo "Installing code-server..."
-apt-get install -y "./code-server_${VERSION}_amd64.deb"
-echo "Installing code-server done."
-
-echo "Cleaning up deb..."
-rm "code-server_${VERSION}_amd64.deb"
-echo "Cleaning up deb done."
-
-append-bash-profile code-server.bash
-
-echo "Setting up code server done."
diff --git a/docker/debian-dev/bootstrap/setup-dev.bash b/docker/debian-dev/bootstrap/setup-dev.bash
deleted file mode 100755
index 92deacb..0000000
--- a/docker/debian-dev/bootstrap/setup-dev.bash
+++ /dev/null
@@ -1,18 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-. /bootstrap/func.bash
-
-echo "Setting up dev function..."
-
-echo "Installing dev packages..."
-apt-get install -y build-essential git devscripts debhelper quilt
-apt-get build-dep -y linux
-echo "Installing dev packages done."
-
-append-bashrc dquilt.bash
-copy-home-dot-file devscripts
-copy-home-dot-file quiltrc-dpkg
-
-echo "Setting up dev function done."
diff --git a/docker/debian-dev/bootstrap/setup-user.bash b/docker/debian-dev/bootstrap/setup-user.bash
deleted file mode 100755
index f74dcdb..0000000
--- a/docker/debian-dev/bootstrap/setup-user.bash
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-echo "Setting up user..."
-
-echo "Installing sudo..."
-apt-get install -y sudo
-echo "Installing sudo done."
-
-echo "Setting up sudo..."
-sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers
-echo "Setting up sudo done."
-
-echo "Adding user $CRUPEST_DEBIAN_DEV_USER ..."
-useradd -m -G sudo -s /usr/bin/bash "$CRUPEST_DEBIAN_DEV_USER"
-echo "Adding user done."
-
-echo "Setting up user done."
-
diff --git a/docker/debian-dev/bootstrap/setup.bash b/docker/debian-dev/bootstrap/setup.bash
index 09b8137..65aabbb 100755
--- a/docker/debian-dev/bootstrap/setup.bash
+++ b/docker/debian-dev/bootstrap/setup.bash
@@ -1,30 +1,56 @@
#! /usr/bin/env bash
+# shellcheck disable=1090,1091
-set -e
+set -e -o pipefail
-export DEBIAN_FRONTEND=noninteractive
+die() {
+ echo "$@" >&2
+ exit 1
+}
+
+if [[ $EUID -ne 0 ]]; then
+ die "This script must be run as root."
+fi
-echo "Setting up crupest-debian-dev..."
+script_dir=$(dirname "$0")
-. /bootstrap/func.bash
+os_release_file="/etc/os-release"
+if [[ -f "$os_release_file" ]]; then
+ debian_version=$(. "$os_release_file"; echo "$VERSION_CODENAME")
+ if [[ "$debian_version" != "bookworm" ]]; then
+ die "This script can only be run on Debian Bookworm. But it is $debian_version"
+ fi
+else
+ die "$os_release_file not found. Failed to get debian version."
+fi
+
+script_dir=$(dirname "$0")
-/bootstrap/apt-source/setup.bash
+export DEBIAN_FRONTEND=noninteractive
-echo "Updating apt source index..."
+echo "Begin to setup debian..."
+
+bash "$script_dir/setup-apt.bash"
+
+echo "Installing packages..."
apt-get update
-echo "Updating apt source index done."
+apt-get install -y \
+ tini locales procps sudo vim less man bash-completion curl wget \
+ build-essential git devscripts debhelper quilt argon2
-/bootstrap/setup-user.bash
-/bootstrap/setup-base.bash
-/bootstrap/setup-dev.bash
+echo "Setting up locale..."
+localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
-if is_true "$CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER"; then
- echo "CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER is true, setting up code-server..."
- /bootstrap/setup-code-server.bash
-fi
+echo "Setting up sudo..."
+sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers
+
+echo "Creating user $CRUPEST_DEBIAN_DEV_USER ..."
+useradd -m -G sudo -s /usr/bin/bash "$CRUPEST_DEBIAN_DEV_USER"
+
+echo "Setting up code-server..."
+curl -fsSL https://code-server.dev/install.sh | sh
echo "Cleaning up apt source index..."
rm -rf /var/lib/apt/lists/*
-echo "Cleaning up apt source index done."
-echo "Setting up crupest-debian-dev done."
+echo "Setup debian done."
diff --git a/docker/debian-dev/bootstrap/start/code-server.bash b/docker/debian-dev/bootstrap/start/code-server.bash
deleted file mode 100755
index 7dfc0e9..0000000
--- a/docker/debian-dev/bootstrap/start/code-server.bash
+++ /dev/null
@@ -1,18 +0,0 @@
-#! /usr/bin/env bash
-
-export CODE_SERVER_CONFIG="/data/code-server-config.yaml"
-
-CODE_SERVER_PROGRAM=code-server
-CODE_SERVER_PORT=8080
-
-if which "$CODE_SERVER_PROGRAM" > /dev/null 2>&1; then
- if ! pgrep -x "$CODE_SERVER_PROGRAM" > /dev/null 2>&1; then
- echo "code-server is not running, starting..."
- "$CODE_SERVER_PROGRAM" "--bind-addr" "0.0.0.0:$CODE_SERVER_PORT"
- else
- echo "code-server is already running."
- fi
-else
- echo "code-server not found, skipping code-server setup." >&2
- exit 1
-fi
diff --git a/docker/debian-dev/bootstrap/wait.bash b/docker/debian-dev/bootstrap/wait.bash
deleted file mode 100755
index 501c706..0000000
--- a/docker/debian-dev/bootstrap/wait.bash
+++ /dev/null
@@ -1,5 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-tail -f /dev/null