Преглед изворни кода

Check that the user exists

Bob Mottram пре 10 година
родитељ
комит
1a798d893d
1 измењених фајлова са 9 додато и 5 уклоњено
  1. 9
    5
      install-freedombone.sh

+ 9
- 5
install-freedombone.sh Прегледај датотеку

94
 function argument_checks {
94
 function argument_checks {
95
   echo './install-freedombone.sh [domain] [username] [subdomain code]'
95
   echo './install-freedombone.sh [domain] [username] [subdomain code]'
96
   echo ''
96
   echo ''
97
+  if [ ! -d /home/$MY_USERNAME ]; then
98
+	  echo "There is no user '$MY_USERNAME' on the system. Use 'adduser $MY_USERNAME' to create the user."
99
+	  exit 1
100
+  fi
97
   if [ ! $DOMAIN_NAME ]; then
101
   if [ ! $DOMAIN_NAME ]; then
98
 	  echo 'Please specify your domain name'
102
 	  echo 'Please specify your domain name'
99
-	  exit
103
+	  exit 2
100
   fi
104
   fi
101
   if [ ! $MY_USERNAME ]; then
105
   if [ ! $MY_USERNAME ]; then
102
 	  echo 'Please specify your username'
106
 	  echo 'Please specify your username'
103
-	  exit
107
+	  exit 3
104
   fi
108
   fi
105
   if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
109
   if [ ! $FREEDNS_SUBDOMAIN_CODE ]; then
106
       echo 'Please specify the freedns subdomain code.  To find it from '
110
       echo 'Please specify the freedns subdomain code.  To find it from '
107
       echo "https://freedns.afraid.org select 'Dynamic DNS', then 'quick "
111
       echo "https://freedns.afraid.org select 'Dynamic DNS', then 'quick "
108
       echo "cron example' and copy the code located between '?' and '=='."
112
       echo "cron example' and copy the code located between '?' and '=='."
109
-	  exit
113
+	  exit 4
110
   fi
114
   fi
111
 }
115
 }
112
 
116
 
845
 	  # use your existing GPG keys which were exported
849
 	  # use your existing GPG keys which were exported
846
 	  if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
850
 	  if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
847
 		  echo "GPG public key file $MY_GPG_PUBLIC_KEY was not found"
851
 		  echo "GPG public key file $MY_GPG_PUBLIC_KEY was not found"
848
-		  exit 1
852
+		  exit 5
849
 	  fi
853
 	  fi
850
 	  if [ ! -f $MY_GPG_PRIVATE_KEY ]; then
854
 	  if [ ! -f $MY_GPG_PRIVATE_KEY ]; then
851
 		  echo "GPG private key file $MY_GPG_PRIVATE_KEY was not found"
855
 		  echo "GPG private key file $MY_GPG_PRIVATE_KEY was not found"
852
-		  exit 1
856
+		  exit 6
853
 	  fi
857
 	  fi
854
       su - $MY_USERNAME gpg --import $MY_GPG_PUBLIC_KEY
858
       su - $MY_USERNAME gpg --import $MY_GPG_PUBLIC_KEY
855
       su - $MY_USERNAME gpg --allow-secret-key-import --import $MY_GPG_PRIVATE_KEY
859
       su - $MY_USERNAME gpg --allow-secret-key-import --import $MY_GPG_PRIVATE_KEY