#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-install-ubuntu-users.txt ######################### #### path: /var/www/ss-install-ubuntu-users ######################################################## #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Reinstalls the Ubuntu (OS) users (sudo/sftp) based on ss-config (idempotent) ######### #### module version: Ubuntu 20.04 LTS ############################################################## #### sourced by: ss-install ######################################################################## #### bash aliases: ss install ubuntu users ######################################################### #################################################################################################### ## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ## ## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ## ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-Install-Ubuntu-Users: Message (Begin Script) ############################################### #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-install-ubuntu-users: Reinstalls the Ubuntu (OS) users (sudo/sftp) based on ss-config (idempotent)... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-Install-Ubuntu-Users: Cleanup Temporary Files ############################################## #################################################################################################### ## delete tmp files ## # n/a #################################################################################################### #### SS-Install-Ubuntu-Users: Configure Root Password + Setup Ubuntu Users ######################### #################################################################################################### ## set root password ## echo "root:$ROOT_PASSWORD" | sudo /usr/sbin/chpasswd ## ensure root password never expires ## # passwd -x -1 chage -E -1 -m 0 -M -1 -I -1 -W 99999 root # chage -E -1 -m 0 -M -1 -I -1 -W 99999 $SUDO_USER # chage -E -1 -m 0 -M -1 -I -1 -W 99999 $SFTP_USER ## create sudo user ## adduser --disabled-password --gecos "" $SUDO_USER # echo "$SUDO_USER:$SUDO_PASSWORD" | sudo /usr/sbin/chpasswd sudo echo "$SUDO_USER:$SUDO_PASSWORD" | sudo /usr/sbin/chpasswd ## create sftp user ## adduser --disabled-password --gecos "" $SFTP_USER # echo "$SFTP_USER:$SFTP_PASSWORD" | sudo /usr/sbin/chpasswd sudo echo "$SFTP_USER:$SFTP_PASSWORD" | sudo /usr/sbin/chpasswd ## ensure wordpress group exists ## addgroup wordpress ## add SFTP_USER and www-data to wordpress group + add SFTP_USER to www-data group ## adduser $SFTP_USER wordpress adduser www-data wordpress adduser $SFTP_USER www-data #################################################################################################### #### SS-Install-Ubuntu-Users: Configure Sudo Permissions (Sudoers File) ############################ #################################################################################################### ## download latest versions ## wget -O /tmp/sudoers http://mirrors.slickstack.io/ubuntu/sudoers.txt ## replace variables ## sed -i "s/@SUDO_USER/${SUDO_USER}/g" /tmp/sudoers ## copy files to their destinations ## cp /tmp/sudoers /etc/sudoers #################################################################################################### #### SS-Install-Ubuntu-Users: Reset Permissions (Ubuntu Users) ##################################### #################################################################################################### ## run ss-perms-ubuntu-users ## source /var/www/ss-perms-ubuntu-users #################################################################################################### #### SS-Install-Ubuntu-Users: Cleanup Temporary Files ############################################## #################################################################################################### ## delete tmp files ## # n/a #################################################################################################### #### SS-Install-Ubuntu-Users: Install (Optimize) Ubuntu Bash ####################################### #################################################################################################### ## here we reinstall bash run commands which requires the users to be installed already ## ## there is no drawback to running this repeatedly so we include it here casually ## ## run ss-install-ubuntu-bash ## source /var/www/ss-install-ubuntu-bash #################################################################################################### #### SS-Install-Ubuntu-Users: Touch Timestamp File (End Script) #################################### #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-install-ubuntu-users #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: ## SS_EOF