Quellcode durchsuchen

Code formatting

mike vor 1 Monat
Ursprung
Commit
1d7dae3a2a
1 geänderte Dateien mit 18 neuen und 16 gelöschten Zeilen
  1. 18 16
      install.sh

+ 18 - 16
install.sh

@@ -20,12 +20,8 @@ helpFunction()
   echo " "
 }
 
-
-
-
 ## Take input and verify file and root user##
 
-filename=$(basename $1)  ##Take Basename in case file in cae user is in unusual directory when calling script.
 projectdir="/home/mike/Software/Nextcloud"
 imagepath="$projectdir/apps"
 executablelink="/usr/local/bin"
@@ -45,30 +41,36 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
   exit 0
 fi
 
-  # Check if user-provided file is valid #
-
-if ! [ -f "$1" ]; then
-  echo "$1 not found."
+# Check if user is root #
+if [ "$USER" != "root" ]; then
+  echo "Must be running as root to install new software.  Use sudo or root user"
   helpFunction
   exit 1
-elif ! [ -f "$imagepath/$filename" ]; then
-  echo "Moving $1 to $imagepath/"
-  mv $1 $imagepath/
-  echo "Done."
 fi
 
-if [ -z "$filename" ]
-then
+# Check if user-provided file is valid #
+if [ -z "$1" ]; then
   echo " "
   echo "No filename given.  Aborting."
   helpFunction
   exit 1
 fi
 
-if [ "$USER" != "root" ]; then
-  echo "Must be running as root to install new software.  Use sudo or root user"
+# Check if the string is a valid file #
+if ! [ -f "$1" ]; then
+  echo "$1 not found."
   helpFunction
   exit 1
+else
+  # Set filename now that we have a good file #
+  filename=$(basename $1)  ##Take Basename in case file in cae user is in unusual directory when calling script.
+fi
+
+# Move file if necessare #
+if ! [ -f "$imagepath/$filename" ]; then
+  echo "Moving $1 to $imagepath/"
+  mv $1 $imagepath/
+  echo "Done."
 fi
 
 # Argument and file checking complete...#