diff --git a/init_root.sh b/init_root.sh index 025a11a..223664e 100755 --- a/init_root.sh +++ b/init_root.sh @@ -3,6 +3,11 @@ scriptdir=$(dirname $(realpath $0)) tempdir="/tmp" +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." + exit 1 +fi + # ============================================================ git_clone() { @@ -188,7 +193,7 @@ configure_timedate() { configure_fail2ban() { [ -f /etc/fail2ban/jail.local ] && return - read -p "要配置 fail2ban 吗?[Y]: " response + read -p "要配置 fail2ban 吗?[N]: " response if [[ $response =~ ^[Yy]$ ]]; then apt install fail2ban @@ -200,10 +205,17 @@ configure_fail2ban() { fi } -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root." - exit 1 -fi +configure_miniconda() { + [ -d ~/.miniconda3 ] && return + + read -p "要安装 miniconda 吗?[N]: " response + + if [[ $response =~ ^[Yy]$ ]]; then + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $tempdir/miniconda.sh + bash $tempdir/miniconda.sh -b -p ~/.miniconda3 + rm $tempdir/miniconda.sh + fi +} check_google_access configure_ssh @@ -216,6 +228,7 @@ configure_apt_install configure_zsh configure_tmux configure_iptables -# configure_hostname +configure_hostname configure_timedate configure_fail2ban +configure_miniconda diff --git a/init_sudo.sh b/init_sudo.sh index eb06580..faec0e6 100755 --- a/init_sudo.sh +++ b/init_sudo.sh @@ -3,6 +3,16 @@ scriptdir=$(dirname $(realpath $0)) tempdir="/tmp" +if [[ $EUID -eq 0 ]]; then + echo "This script should not be run as root." + exit 1 +fi + +if ! sudo -v; then + echo "Please get sudo access first." + exit 1 +fi + # ============================================================ git_clone() { @@ -189,7 +199,7 @@ configure_timedate() { configure_fail2ban() { [ -f /etc/fail2ban/jail.local ] && return - read -p "要配置 fail2ban 吗?[Y]: " response + read -p "要配置 fail2ban 吗?[N]: " response if [[ $response =~ ^[Yy]$ ]]; then sudo apt install fail2ban @@ -201,10 +211,17 @@ configure_fail2ban() { fi } -if [[ $EUID -eq 0 ]]; then - echo "This script should not be run as root." - exit 1 -fi +configure_miniconda() { + [ -d ~/.miniconda3 ] && return + + read -p "要安装 miniconda 吗?[N]: " response + + if [[ $response =~ ^[Yy]$ ]]; then + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $tempdir/miniconda.sh + bash $tempdir/miniconda.sh -b -p ~/.miniconda3 + rm $tempdir/miniconda.sh + fi +} check_google_access configure_ssh @@ -217,6 +234,7 @@ configure_apt_install configure_zsh configure_tmux configure_iptables -# configure_hostname +configure_hostname configure_timedate configure_fail2ban +configure_miniconda