diff --git a/init_root.sh b/init_root.sh index 953591e..62b374c 100755 --- a/init_root.sh +++ b/init_root.sh @@ -23,6 +23,16 @@ git_clone() { fi } +update_file() { + local A="$1" + local B="$2" + + if [ -f "$A" ] && [ -f "$B" ] && [ "$(cat "$A")" != "$(cat "$B")" ]; then + cp "$A" "$B" + echo "File $B has been updated." + fi +} + # ============================================================ check_google_access() { @@ -40,6 +50,10 @@ check_google_access() { fi } +update_files() { + update_file $scriptdir/files/ys-simple.zsh-theme ~/.oh-my-zsh/themes/ys-simple.zsh-theme +} + configure_ssh() { [ -f ~/.ssh/authorized_keys ] && return @@ -232,7 +246,18 @@ configure_git() { fi } +configure_docker() { + [ -f /etc/docker/daemon.json ] && return + + read -p "要配置 Docker (Rootless mode) 吗?[N]: " response + + if [[ $response =~ ^[Yy]$ ]]; then + cp $scriptdir/files/docker-rootless-daemon.json /etc/docker/daemon.json + fi +} + check_google_access +update_files configure_ssh configure_ssh_keygen configure_nano @@ -248,3 +273,4 @@ configure_timedate configure_fail2ban configure_miniconda configure_git +# configure_docker diff --git a/init_sudo.sh b/init_sudo.sh index f97bb58..0d69055 100755 --- a/init_sudo.sh +++ b/init_sudo.sh @@ -28,6 +28,16 @@ git_clone() { fi } +update_file() { + local A="$1" + local B="$2" + + if [ -f "$A" ] && [ -f "$B" ] && [ "$(cat "$A")" != "$(cat "$B")" ]; then + cp "$A" "$B" + echo "File $B has been updated." + fi +} + # ============================================================ check_google_access() { @@ -45,6 +55,10 @@ check_google_access() { fi } +update_files() { + update_file $scriptdir/files/ys-simple.zsh-theme ~/.oh-my-zsh/themes/ys-simple.zsh-theme +} + configure_ssh() { [ -f ~/.ssh/authorized_keys ] && return @@ -238,7 +252,18 @@ configure_git() { fi } +configure_docker_rootless() { + [ -f ~/.config/docker/daemon.json ] && return + + read -p "要配置 Docker (Rootless mode) 吗?[N]: " response + + if [[ $response =~ ^[Yy]$ ]]; then + cp $scriptdir/files/docker-rootless-daemon.json ~/.config/docker/daemon.json + fi +} + check_google_access +update_files configure_ssh configure_ssh_keygen configure_nano @@ -254,3 +279,4 @@ configure_timedate configure_fail2ban configure_miniconda configure_git +# configure_docker_rootless