u
This commit is contained in:
		
							parent
							
								
									72f4b05e76
								
							
						
					
					
						commit
						c7e9c53601
					
				| @ -1,5 +1,6 @@ | ||||
| echo "Usage: setup.sh [USER]" | ||||
| echo "Example: setup.sh alice" | ||||
| echo | ||||
| 
 | ||||
| NewUser=$1 | ||||
| while [ ! "$NewUser" ] | ||||
| @ -22,7 +23,7 @@ sed -i "s|/home/$NewUser:/bin/sh$|/home/$NewUser:/bin/bash|g" /etc/passwd | ||||
| # Debian 9 default to empty | ||||
| sed -i "s|/home/$NewUser:$|/home/$NewUser:/bin/bash|g" /etc/passwd | ||||
| 
 | ||||
| echo "=== Allow the new user $NewUser to sudo without password? <y> for yes, <anything else> for no" | ||||
| echo "=== Allow the new user [$NewUser] to sudo without password? <y> for yes, <anything else> for no" | ||||
| read -p ">>> " AllowSudo | ||||
| if [ "$AllowSudo" == "y" ] | ||||
| then | ||||
| @ -35,7 +36,7 @@ else | ||||
| fi | ||||
| echo | ||||
| 
 | ||||
| echo "=== Configure $NewUser home with standard scripts? <y> for yes, <anything else> for no" | ||||
| echo "=== Configure $NewUser's home with standard scripts? <y> for yes, <anything else> for no" | ||||
| read -p ">>> " ConfigHome | ||||
| if [ "$ConfigHome" == 'y' ] | ||||
| then | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| 
 | ||||
| echo "Usage: this.sh [NewUser]" | ||||
| echo "Example: this.sh alice" | ||||
| echo " curl https://git.faronear.org/fon/sysconfig/raw/branch/main/debian-config.sh | bash" | ||||
| echo "curl https://git.faronear.org/fon/sysconfig/raw/branch/main/debian-config.sh | sudo bash" | ||||
| 
 | ||||
| if [ v$1 != v ] | ||||
| then | ||||
| @ -50,7 +50,7 @@ then | ||||
| fi | ||||
| echo  | ||||
| 
 | ||||
| echo "=== Configure /etc/sudoers" | ||||
| echo "=== Configure /etc/sudoers: includedir /etc/sudoers.d" | ||||
| chmod o+w /etc/sudoers | ||||
| #sed -i "s|%sudo\s\+ALL=(ALL:ALL)\sALL|%sudo\tALL=(ALL:ALL) NOPASSWD:ALL|g" /etc/sudoers  # allow all users in %sudo group to sudo without password | ||||
| sed -i "s|#includedir /etc/sudoers.d|@includedir /etc/sudoers.d|g" /etc/sudoers  # allow users in /etc/sudoers.d/ folder to sudo | ||||
| @ -75,15 +75,15 @@ fi | ||||
| echo | ||||
| 
 | ||||
| echo "=== Configure autostart" | ||||
| if [ -f /etc/rc.local ] | ||||
| if [ ! -f /etc/rc.local ] | ||||
| then | ||||
|   mv /etc/rc.local /etc/rc.local.backup | ||||
|   echo '#!/bin/bash' > /etc/rc.local # can't omit, otherwise you can't launch pm2 in autostart.sh. Don't use double quote here, otherwise error. | ||||
| fi | ||||
| touch /etc/rc.local | ||||
| chmod +x /etc/rc.local | ||||
| echo '#!/bin/bash' > /etc/rc.local # can't omit, otherwise you can't launch pm2 in autostart.sh. Don't use double quote here, otherwise error. | ||||
| echo 'source /faronear/autostart.sh' >> /etc/rc.local # make sure to sudo pm2 in autostart.sh, otherwise pm2 list can't find it as root. | ||||
| 
 | ||||
| echo 'source /faronear/autostart.sh' >> /etc/rc.local | ||||
| touch /faronear/autostart.sh | ||||
| echo "# make sure to sudo in autostart.sh, otherwise for example pm2 list can't find it as root." >> /faronear/autostart.sh | ||||
| chmod +x /faronear/autostart.sh | ||||
| echo 'Autostart is set to /faronear/autostart.sh. Run "systemctl start/stop/status rc-local" to manage it.' | ||||
| echo | ||||
|  | ||||
| @ -39,22 +39,22 @@ then | ||||
|   read -p "Enter root password (YU) >>" PWD_ROOT | ||||
|   expect ~/faronear/fon/sysconfig/expect-ssh.sh $targetUrl adot $PWD_ADOT $PWD_ADOT | ||||
| else | ||||
|   while [ "$HOST" ] | ||||
|   while [ ! "$HOST" ] | ||||
|   do | ||||
|   read -p "host = " HOST | ||||
|   done | ||||
| 
 | ||||
|   while [ "$USER" ] | ||||
|   while [ ! "$USER" ] | ||||
|   do | ||||
|     read -p "user = " USER | ||||
|   done | ||||
|    | ||||
|   while [ "$PWD_USER" ] | ||||
|   while [ ! "$PWD_USER" ] | ||||
|   do | ||||
|     read -p "user password = " PWD_USER | ||||
|   done | ||||
| 
 | ||||
|   while [ "$PWD_SU" ] | ||||
|   while [ ! "$PWD_SU" ] | ||||
|   do | ||||
|     read -p "root password = " ROOT_SU | ||||
|   done | ||||
|  | ||||
| @ -36,7 +36,7 @@ if [ "$2" ] | ||||
| then | ||||
|   HomePath=/home/$2 | ||||
| else | ||||
|   HomePath=~ | ||||
|   HomePath=/root | ||||
| fi | ||||
| 
 | ||||
| if [ -d "$HomePath" ] | ||||
| @ -48,7 +48,10 @@ then | ||||
|   read -p ">>> " CopyOrLinkScripts | ||||
|   for homescript in $homescriptlist | ||||
|   do | ||||
|     mv $homescript $homescript.backup-$(date +%Y%m%d%H%M%S) | ||||
|     if [ -e "$homescript" ] | ||||
|     then | ||||
|       mv $homescript $homescript.backup-$(date +%Y%m%d%H%M%S) | ||||
|     fi | ||||
|     if [ "$CopyOrLinkScripts" = 'l' ] | ||||
|     then | ||||
|       echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..." | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user