mirror of
https://github.com/nextcloud/vm.git
synced 2025-10-26 11:27:32 +00:00
Change UNIXUSER to $SUDO_USER (#107)
This commit is contained in:
parent
1b88865080
commit
35225da68f
@ -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..."
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
UNIXUSER=ncadmin
|
||||
UNIXUSER=$SUDO_USER
|
||||
UNIXUSER_PROFILE="/home/$UNIXUSER/.bash_profile"
|
||||
|
||||
rm /home/$UNIXUSER/.profile
|
||||
|
||||
Loading…
Reference in New Issue
Block a user