Change UNIXUSER to $SUDO_USER (#107)

This commit is contained in:
Daniel Hansson 2017-01-31 22:25:16 +01:00 committed by GitHub
parent 1b88865080
commit 35225da68f
3 changed files with 22 additions and 26 deletions

View File

@ -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 <user> and <pass> in the script"
fi
clear
# Upgrade system
echo "System will now upgrade..."

View File

@ -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

View File

@ -1,6 +1,6 @@
#!/bin/bash
UNIXUSER=ncadmin
UNIXUSER=$SUDO_USER
UNIXUSER_PROFILE="/home/$UNIXUSER/.bash_profile"
rm /home/$UNIXUSER/.profile