Skip to content

Commit

Permalink
added more parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
PietsHost committed Apr 25, 2017
1 parent 75a9e8b commit c4f32c4
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 74 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ chmod +x ./nc_install.sh

-h --help display this help and exit
-v --version specify Nextcloud Version (e.g. 10.0.0)
-p --password sets the MySQL root password. Type -p "P@s§"
-p --password sets the MySQL root password. Type -p "P@s"
-r --root sets the MySQL root user
-m --mysqlhost sets the MySQL Host
-n --name sets the Nextcloud name, used for Database
-u --url sets the URL for Nextcloud installation
-d --directory sets the full installation path
-f --folder sets the desired folder (example.com/folder). May be empty
-s --smtp setup SMTP during script run (no argument required)
-a --apps setup additionals apps during run (no argument required)
-s --smtp setup SMTP during script run (Type -s "y" or -s "n")
-a --apps setup additionals apps during run (Type -a "y" or -a "n")

If you want to install v9.0.53 for example, use:<br />
`./nc_install.sh -v 9.0.53` or `./nc_install.sh --version 9.0.53`
Expand Down
189 changes: 118 additions & 71 deletions nc_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ cat << EOF
-h --help display this help and exit
-v --version specify Nextcloud Version (e.g. 10.0.0)
-p --password sets the MySQL root password. Type -p "P@s§"
-r --root sets the MySQL root user
-m --mysqlhost sets the MySQL Host
-n --name sets the Nextcloud name, used for Database
-u --url sets the URL for Nextcloud installation
-d --directory sets the full installation path
-f --folder sets the desired folder (example.com/folder). May be empty
-s --smtp setup SMTP during script run (no argument required)
-a --apps setup additionals apps during run (no argument required)
-s --smtp setup SMTP during script run (Type -s "y" or -s "n")
-a --apps setup additionals apps during run (Type -a "y" or -a "n")
EOF
}
Expand All @@ -106,7 +108,6 @@ while :; do
fi
;;
-p|--password)
echo "$database_root"
if [ -n "$2" ]; then
database_root="$2"
shift
Expand All @@ -116,6 +117,28 @@ while :; do
stty echo
exit 1
fi
;;
-r|--root)
if [ -n "$2" ]; then
dbruser="$2"
shift
else
printf $redbg'ERROR: "--root" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-m|--mysqlhost)
if [ -n "$2" ]; then
dbhost="$2"
shift
else
printf $redbg'ERROR: "--mysqlhost" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-n|--name)
if [ -n "$2" ]; then
Expand Down Expand Up @@ -155,12 +178,26 @@ while :; do
shift
;;
-s|--smtp)
smtp="y"
if [ -n "$2" ]; then
smtp="$2"
shift
else
printf $redbg'ERROR: "--smtp" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-a|--apps)
appsinstall="y"
if [ -n "$2" ]; then
appsinstall="$2"
shift
else
printf $redbg'ERROR: "--apps" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
--) # End of all options.
shift
Expand Down Expand Up @@ -256,19 +293,33 @@ printf $yellow"Installing dependencies...\n"$reset
if [[ "$os" = "Ubuntu" && ("$ver" = "12.04" || "$ver" = "14.04" || "$ver" = "16.04" ) ]]; then
htuser='www-data'
htgroup='www-data'
sudo apt-get install -y pv bzip2 rsync bc
dpkg -l | grep -qw pv || apt-get install pv
dpkg -l | grep -qw bzip2 || apt-get install bzip2
dpkg -l | grep -qw rsync || apt-get install rsync
dpkg -l | grep -qw bc || apt-get install bc
elif [[ "$os" = "debian" && ("$ver" = "7" || "$ver" = "8" ) ]]; then
htuser='www-data'
htgroup='www-data'
apt-get install pv && apt-get install bzip2 && apt-get install rsync && apt-get install bc
dpkg -l | grep -qw pv || apt-get install pv
dpkg -l | grep -qw bzip2 || apt-get install bzip2
dpkg -l | grep -qw rsync || apt-get install rsync
dpkg -l | grep -qw bc || apt-get install bc
elif [[ "$os" = "CentOs" && ("$ver" = "6" || "$ver" = "7" ) ]]; then
htuser='apache'
htgroup='apache'
yum install -y pv bzip2 rsync php-process bc
rpm -qa | grep -qw pv || yum install pv
rpm -qa | grep -qw bc || yum install bc
rpm -qa | grep -qw bzip2 || yum install bzip2
rpm -qa | grep -qw rsync || yum install rsync
rpm -qa | grep -qw php-process || yum install php-process
elif [[ "$os" = "fedora" && ("$ver" = "23" || "$ver" = "25") ]]; then
htuser='apache'
htgroup='apache'
dnf install pv bzip2 rsync php-process bc
rpm -qa | grep -qw pv || dnf install pv
rpm -qa | grep -qw bc || dnf install bc
rpm -qa | grep -qw bzip2 || dnf install bzip2
rpm -qa | grep -qw rsync || dnf install rsync
rpm -qa | grep -qw php-process || dnf install php-process
fi
} &> /dev/null

Expand Down Expand Up @@ -319,6 +370,12 @@ function checkapps(){
[ -z "$galleryinstall" ] && gallerystat="$check_miss" || gallerystat="$check_ok"
}

function printhead {
clear
printf $green"$header"$reset
echo ""
}

# autoinput on keypress
readOne () {
stty echo
Expand Down Expand Up @@ -468,9 +525,7 @@ function progress () {
function smtpsetup(){
clear
while true; do
clear
printf $green"$header"$reset
echo ""
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------------"
Expand Down Expand Up @@ -598,9 +653,7 @@ checkapps

clear
while true; do
clear
printf $green"$header"$reset
echo ""
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------"
Expand Down Expand Up @@ -752,9 +805,7 @@ stty echo
# clear user input
read -t 1 -n 100 discard

clear
printf $green"$header"$reset
echo ""
printhead
echo ""

echo "--------------------------------------------------------"
Expand Down Expand Up @@ -788,9 +839,7 @@ if [ "$key" = '' ]; then
fi
echo ""
stty -echo
clear
printf $green"$header"$reset
echo ""
printhead
echo ""

#################################
Expand All @@ -811,9 +860,7 @@ stty echo
check
clear
while true; do
clear
printf $green"$header"$reset
echo ""
printhead
echo ""

echo "--------------------------------------------------------------------------"
Expand Down Expand Up @@ -951,9 +998,7 @@ stty echo

clear
while true; do
clear
printf $green"$header"$reset
echo ""
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------------"
Expand Down Expand Up @@ -1100,9 +1145,7 @@ sleep 1

clear
while true; do
clear
printf $green"$header"$reset
echo ""
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------------"
Expand Down Expand Up @@ -1282,25 +1325,26 @@ done
#################################

# ask for SMTP-Setup
clear
printf $green"$header"$reset
echo ""
printhead
if [ "$smtp" == "y" ] || [ "$smtp" == "Y" ]; then
echo ""
smtpsetup
else
elif [ "$smtp" == "n" ] || [ "$smtp" == "N" ]; then
printhead
echo ""
printf "Skipping SMTP Setup..."
sleep 1
elif [ -z "$smtp" ]; then
echo ""
echo -en "Do you want to setup SMTP (y/n)? ";smtp=$(readOne)
if [ "$smtp" == "y" ] || [ "$smtp" == "Y" ]; then
smtpsetup

else
clear
printf $green"$header"$reset"\n"
echo ""
printf "Skipping SMTP Setup..."
sleep 2
fi
smtpsetup
else
printhead
echo ""
printf "Skipping SMTP Setup..."
sleep 1
fi
fi
sleep 1
###############################
Expand All @@ -1312,42 +1356,48 @@ sleep 1
#################################

# ask for Apps-Setup
clear
printf $green"$header"$reset
echo ""
printhead
if [ "$appsinstall" == "y" ] || [ "$appsinstall" == "Y" ]; then
echo ""
installapps
else
elif [ "$appsinstall" == "n" ] || [ "$appsinstall" == "N" ]; then
contactsinstall='false'
calendarinstall='false'
mailinstall='false'
notesinstall='false'
tasksinstall='false'
galleryinstall'false'
printhead
echo ""
printf "Skipping Apps Setup..."
sleep 1

elif [ -z "$appsinstall" ]; then
echo ""
echo -en "Do you want to setup additional Apps (y/n)? ";appsinstall=$(readOne)
echo -en "Do you want to setup additional Apps (y/n)? ";appsinstall=$(readOne)
if [ "$appsinstall" == "y" ] || [ "$appsinstall" == "Y" ]; then
installapps

else
contactsinstall='false'
calendarinstall='false'
mailinstall='false'
notesinstall='false'
tasksinstall='false'
galleryinstall'false'
clear
printf $green"$header"$reset"\n"
echo ""
printf "Skipping Apps Setup..."
sleep 2
fi
else
contactsinstall='false'
calendarinstall='false'
mailinstall='false'
notesinstall='false'
tasksinstall='false'
galleryinstall'false'
printhead
echo ""
printf "Skipping Apps Setup..."
sleep 1
fi
fi
stty -echo

###############################
###### Apps-Setup End #####
###############################

clear
printf $green"$header"$reset"\n"
printhead
echo ""

# Get latest nextcloud version
if [[ -n "$version" ]]; then
ncversion=${version}
Expand Down Expand Up @@ -1442,9 +1492,7 @@ echo ""
echo ""
sleep 1

clear
printf $green"$header"$reset"\n"
echo ""
printhead
echo ""
####################
## PASSWORD-GEN ##
Expand Down Expand Up @@ -1791,8 +1839,7 @@ echo "Database password : $dbpwd"
} > /root/${ncname}_passwords.txt

{
clear
printf $green"$header"$reset"\n"
printhead
echo ""
echo "###################################################################"
echo " Congratulations. Nextcloud has now been successfully"
Expand Down Expand Up @@ -1830,7 +1877,7 @@ printf $green"Navigate to $url and enjoy Nextcloud!\n"$reset
printf $green"sudo -u ${htuser} php $ncpath/occ singleuser:mode --off"$reset
sleep 2
fi

rm -f nextcloud-$ncversion.tar.bz2
echo ""
} &>/dev/tty
stty echo
Expand Down

0 comments on commit c4f32c4

Please sign in to comment.