|
@@ -20,12 +20,8 @@ helpFunction()
|
|
|
echo " "
|
|
echo " "
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
## Take input and verify file and root user##
|
|
## 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"
|
|
projectdir="/home/mike/Software/Nextcloud"
|
|
|
imagepath="$projectdir/apps"
|
|
imagepath="$projectdir/apps"
|
|
|
executablelink="/usr/local/bin"
|
|
executablelink="/usr/local/bin"
|
|
@@ -45,30 +41,36 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
exit 0
|
|
exit 0
|
|
|
fi
|
|
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
|
|
helpFunction
|
|
|
exit 1
|
|
exit 1
|
|
|
-elif ! [ -f "$imagepath/$filename" ]; then
|
|
|
|
|
- echo "Moving $1 to $imagepath/"
|
|
|
|
|
- mv $1 $imagepath/
|
|
|
|
|
- echo "Done."
|
|
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-if [ -z "$filename" ]
|
|
|
|
|
-then
|
|
|
|
|
|
|
+# Check if user-provided file is valid #
|
|
|
|
|
+if [ -z "$1" ]; then
|
|
|
echo " "
|
|
echo " "
|
|
|
echo "No filename given. Aborting."
|
|
echo "No filename given. Aborting."
|
|
|
helpFunction
|
|
helpFunction
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
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
|
|
helpFunction
|
|
|
exit 1
|
|
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
|
|
fi
|
|
|
|
|
|
|
|
# Argument and file checking complete...#
|
|
# Argument and file checking complete...#
|