diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 31d249d4..5852ac0f 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -17,8 +17,9 @@ PHPMYADMIN_CONF="/etc/apache2/conf-available/phpmyadmin.conf" GITHUB_REPO="https://raw.githubusercontent.com/nextcloud/vm/master" STATIC="https://raw.githubusercontent.com/nextcloud/vm/master/static" LETS_ENC="https://raw.githubusercontent.com/nextcloud/vm/master/lets-encrypt" -UNIXUSER=ncadmin -UNIXPASS=nextcloud +UNIXUSER=$SUDO_USER +NCPASS=nextcloud +NCUSER=ncadmin # DEBUG mode if [ $DEBUG -eq 1 ] @@ -604,12 +605,9 @@ echo sleep 3 clear -if [ "$UNIXUSER" = "ncadmin" ] -then # Change password echo -e "\e[0m" echo "For better security, change the Linux password for [$UNIXUSER]" - echo "The current password is [$UNIXPASS]" echo -e "\e[32m" read -p "Press any key to change password for Linux... " -n1 -s echo -e "\e[0m" @@ -624,22 +622,19 @@ then clear echo -e "\e[0m" - echo "For better security, change the Nextcloud password for [$UNIXUSER]" - echo "The current password is [$UNIXPASS]" + echo "For better security, change the Nextcloud password for [$NCUSER]" + echo "The current password for $NCUSER is [$NCPASS]" echo -e "\e[32m" read -p "Press any key to change password for Nextcloud... " -n1 -s echo -e "\e[0m" - sudo -u www-data php $NCPATH/occ user:resetpassword $UNIXUSER + sudo -u www-data php $NCPATH/occ user:resetpassword $NCUSER if [[ $? > 0 ]] then - sudo -u www-data php $NCPATH/occ user:resetpassword $UNIXUSER + sudo -u www-data php $NCPATH/occ user:resetpassword $NCUSER else sleep 2 fi - clear -else - echo "Not changing password as you already changed and in the script" -fi +clear # Upgrade system echo "System will now upgrade..." diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 10a166a3..7f669fc3 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -39,8 +39,9 @@ IFACE=$(lshw -c network | grep "logical name" | awk '{print $3; exit}') ADDRESS=$(hostname -I | cut -d ' ' -f 1) # Linux user, and Nextcloud user -UNIXUSER=ncadmin -UNIXPASS=nextcloud +UNIXUSER=$SUDO_USER +NCPASS=nextcloud +NCUSER=ncadmin # DEBUG mode if [ $DEBUG -eq 1 ] @@ -127,19 +128,19 @@ then exit 1 fi -# Create $UNIXUSER if not existing -if id "$UNIXUSER" >/dev/null 2>&1 +# Create $NCUSER if not existing +if id "$NCUSER" >/dev/null 2>&1 then - echo "$UNIXUSER already exists!" + echo "$NCUSER already exists!" else - adduser --disabled-password --gecos "" $UNIXUSER - echo -e "$UNIXUSER:$UNIXPASS" | chpasswd - usermod -aG sudo $UNIXUSER + adduser --disabled-password --gecos "" $NCUSER + echo -e "$NCUSER:$NCPASS" | chpasswd + usermod -aG sudo $NCUSER fi -if [ -d /home/$UNIXUSER ] +if [ -d /home/$NCUSER ] then - echo "$UNIXUSER OK!" + echo "$NCUSER OK!" else echo "Something went wrong when creating the user... Script will exit." exit 1 @@ -332,8 +333,8 @@ sudo -u www-data php occ maintenance:install \ --database-name "nextcloud_db" \ --database-user "root" \ --database-pass "$MYSQL_PASS" \ - --admin-user "$UNIXUSER" \ - --admin-pass "$UNIXPASS" + --admin-user "$NCUSER" \ + --admin-pass "$NCPASS" echo echo "Nextcloud version:" sudo -u www-data php $NCPATH/occ status diff --git a/static/change-ncadmin-profile.sh b/static/change-ncadmin-profile.sh index 060a1361..86ebd09a 100644 --- a/static/change-ncadmin-profile.sh +++ b/static/change-ncadmin-profile.sh @@ -1,6 +1,6 @@ #!/bin/bash -UNIXUSER=ncadmin +UNIXUSER=$SUDO_USER UNIXUSER_PROFILE="/home/$UNIXUSER/.bash_profile" rm /home/$UNIXUSER/.profile