Bohan Yang 5 年之前
父節點
當前提交
7f6a25aa60
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      debi.sh

+ 10 - 2
debi.sh

@@ -12,12 +12,15 @@ command_exists() {
     command -v "$1" > /dev/null 2>&1
     command -v "$1" > /dev/null 2>&1
 }
 }
 
 
+# Sets variable:
 late_command=
 late_command=
 in_target() {
 in_target() {
     local command=
     local command=
+
     for argument in "$@"; do
     for argument in "$@"; do
         command="$command $argument"
         command="$command $argument"
     done
     done
+
     if [ -n "$command" ]; then
     if [ -n "$command" ]; then
         [ -z "$late_command" ] && late_command='true'
         [ -z "$late_command" ] && late_command='true'
         late_command="$late_command;$command"
         late_command="$late_command;$command"
@@ -29,13 +32,15 @@ in_target_backup() {
 }
 }
 
 
 configure_sshd() {
 configure_sshd() {
-    [ -z ${backup_sshd_config+1} ] && in_target_backup /etc/ssh/sshd_config
+    # !isset($backup_sshd_config)
+    [ -z ${backup_sshd_config+1s} ] && in_target_backup /etc/ssh/sshd_config
     backup_sshd_config=
     backup_sshd_config=
     in_target sed -Ei \""s/^#?$1 .+/$1 $2/"\" /etc/ssh/sshd_config
     in_target sed -Ei \""s/^#?$1 .+/$1 $2/"\" /etc/ssh/sshd_config
 }
 }
 
 
 prompt_password() {
 prompt_password() {
     local prompt=
     local prompt=
+
     if [ $# -gt 0 ]; then
     if [ $# -gt 0 ]; then
         prompt=$1
         prompt=$1
     elif [ "$username" = root ]; then
     elif [ "$username" = root ]; then
@@ -43,13 +48,16 @@ prompt_password() {
     else
     else
         prompt="Choose a password for user $username: "
         prompt="Choose a password for user $username: "
     fi
     fi
+
     stty -echo
     stty -echo
     trap 'stty echo' EXIT
     trap 'stty echo' EXIT
+
     while [ -z "$password" ]; do
     while [ -z "$password" ]; do
         echo -n "$prompt" > /dev/tty
         echo -n "$prompt" > /dev/tty
         read -r password < /dev/tty
         read -r password < /dev/tty
         echo > /dev/tty
         echo > /dev/tty
     done
     done
+
     stty echo
     stty echo
     trap - EXIT
     trap - EXIT
 }
 }
@@ -267,7 +275,7 @@ while [ $# -gt 0 ]; do
             dry_run=true
             dry_run=true
             ;;
             ;;
         *)
         *)
-            err "No such option: \"$1\""
+            err "Unknown option: \"$1\""
     esac
     esac
     shift
     shift
 done
 done