Increase the view of the vars in printf
This commit is contained in:
		
							parent
							
								
									c21a895747
								
							
						
					
					
						commit
						725277623c
					
				|  | @ -22,17 +22,17 @@ function AllowUserToConnectToThisMachineUsingSsh() | |||
| { | ||||
| 	local userLogin | ||||
| 	userLogin="$1" | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Autoriser les accès SSH pour l'utilisateur (${userLogin})." | ||||
| 	dscl . append '/Groups/com.apple.access_ssh' user "${userLogin}" | ||||
| 	dscl . append /Groups/com.apple.access_ssh groupmembers $(dscl . read "/Users/${userLogin}" GeneratedUID | cut -d " " -f 2) | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Autoriser les accès SSH pour ${userLogin}." | ||||
| } | ||||
| ## }}} | ||||
| 
 | ||||
| ## EnsurePingIsAllowed {{{ | ||||
| function EnsurePingIsAllowed() | ||||
| { | ||||
| 	sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off &> /dev/null | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Désactivation du mode furtif (ping)." | ||||
| 	sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off &> /dev/null | ||||
| 	if [ $? != 0 ]; then | ||||
| 		printf '\e[1;31m%-6s\e[m\n' "ERREUR : La désactivation du mode furtif a échoué" | ||||
| 		return "$ERROR" | ||||
|  | @ -43,15 +43,15 @@ function EnsurePingIsAllowed() | |||
| ## EnsureSshdIsRunning {{{ | ||||
| function EnsureSshdIsRunning() | ||||
| { | ||||
| 	sudo launchctl list | grep 'com.openssh.sshd' &> /dev/null | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Vérification si sshd est déjà en cours." | ||||
| 	sudo launchctl list | grep 'com.openssh.sshd' &> /dev/null | ||||
| 	if [ $? != 0 ]; then | ||||
| 		# enable 'Remote login' in 'system preferences' | ||||
| 		sudo launchctl enable system/com.openssh.sshd &> /dev/null | ||||
| 		sudo launchctl load /System/Library/LaunchDaemons/ssh.plist &> /dev/null | ||||
| 	fi | ||||
| 	sudo launchctl list | grep 'com.openssh.sshd' &> /dev/null | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Activation du serveur ssh." | ||||
| 	sudo launchctl list | grep 'com.openssh.sshd' &> /dev/null | ||||
| 	if [ $? != 0 ]; then | ||||
| 		printf '\e[1;31m%-6s\e[m\n' "ERREUR : L'activation du serveur ssh a échoué"; | ||||
| 		return "$ERROR" | ||||
|  | @ -134,6 +134,7 @@ function AddUserBackuppc() { | |||
| 	fi | ||||
| 
 | ||||
| 	# Create user | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création de l'utilisateur ${userLogin}." | ||||
| 	dscl . -create "/Users/$userLogin" | ||||
| 	dscl . -create "/Users/$userLogin" UserShell /bin/bash | ||||
| 	dscl . -create "/Users/$userLogin" RealName "backuppc" | ||||
|  | @ -141,11 +142,10 @@ function AddUserBackuppc() { | |||
| 	dscl . -create "/Users/$userLogin" PrimaryGroupID "$groupId" | ||||
| 	dscl . -create "/Users/$userLogin" NFSHomeDirectory "$homeDir" | ||||
| 	dscl . -create "/Users/$userLogin" IsHidden 1 # hide from login window | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création de l'utilisateur ${userLogin}." | ||||
| 
 | ||||
| 	# Homedir permissions | ||||
| 	chown -R "$userLogin:$groupId" "$homeDir" | ||||
| 	[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : chown -R $userLogin:$groupId $homeDir" | ||||
| 	chown -R "$userLogin:$groupId" "$homeDir" | ||||
| 
 | ||||
| 	AllowUserToConnectToThisMachineUsingSsh "${userLogin}" | ||||
| 
 | ||||
|  | @ -163,8 +163,8 @@ function AllowBackuppcSudo() { | |||
| 		if [ ! "${sudoersDir}" == '' ]; then | ||||
| 			printf '%b\n' "Configuration de sudo pour BackupPC." | ||||
| 		else | ||||
| 				[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout du dossier sudoers (${sudoersDir}) dans la configuration sudo." | ||||
| 				echo "#includedir /etc/sudoers.d" >> /etc/sudoers | ||||
| 				[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout de ${sudoersDir} dans le fichier sudoers." | ||||
| 		fi | ||||
| 	elif [ -f /private/etc/sudoers ]; then | ||||
| 		sudoersDir=$(grep "^#includedir " /private/etc/sudoers | cut -d" " -f2) | ||||
|  | @ -172,7 +172,7 @@ function AllowBackuppcSudo() { | |||
| 			printf '%b\n' "Configuration de sudo pour BackupPC." | ||||
| 		else | ||||
| 			echo "#includedir /private/etc/sudoers.d" >> /private/etc/sudoers | ||||
| 			[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout de ${sudoersDir} dans le fichier sudoers." | ||||
| 			[[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout du dossier sudoers (${sudoersDir}) dans la configuration sudo." | ||||
| 		fi | ||||
| 	else | ||||
| 		printf '\e[1;31m%-6s\e[m\n' "ERREUR : Impossible de trouver un fichier de configuratio pour sudo." | ||||
|  | @ -181,12 +181,11 @@ function AllowBackuppcSudo() { | |||
| 
 | ||||
| # Ensure to create the sudoers directory | ||||
| 	sudo mkdir -p -- "${sudoersDir}" | ||||
| [[ "${DEBUG}" == "0" ]] && 	printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création du dossier pour les sudoers ${sudoersDir}." | ||||
| [[ "${DEBUG}" == "0" ]] && 	printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création du dossier pour les sudoers (${sudoersDir})." | ||||
| 
 | ||||
| 	# Allow backuppc user to use rsync with sudo | ||||
| 	sudo sh -c "echo '${userLogin} ALL=(ALL:ALL)  NOEXEC:NOPASSWD: /usr/bin/rsync' > ${sudoersDir}/backuppc_noexec" | ||||
| [[ "${DEBUG}" == "0" ]] && 	printf '\e[1;33m%-6s\e[m\n' "DEBUG : ajout de '${userLogin} ALL=(ALL:ALL)  NOEXEC:NOPASSWD: /usr/bin/rsync'" | ||||
| [[ "${DEBUG}" == "0" ]] && 	printf '\e[1;33m%-6s\e[m\n' "DEBUG : dans le fichier ${sudoersDir}/backuppc_noexec." | ||||
| 	[[ "${DEBUG}" == "0" ]] && 	printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout des autorisations sudo pour l'utilisateur (${userLogin}) dans le fichier (${sudoersDir}/backuppc_noexec)." | ||||
| } | ||||
| ## }}} | ||||
| # }}} | ||||
|  | @ -313,12 +312,12 @@ mv -f -- "${filepl}" "${dir1}" | |||
| #### CRÉATION DE L’UTILISATEUR BACKUPPC #### | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Partie - Création du compte backuppc" | ||||
| homebackuppc='/var/lib/backuppc' | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création de l'utilisateur backuppc (homebackuppc=${homebackuppc}) avec des droits sur l'utilisateur ${usr}." | ||||
| AddUserBackuppc "${input_login}" "${homebackuppc}" | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création de l'utilisateur backuppc (homebackuppc=${homebackuppc}) avec des droits sur l'utilisateur (${usr})." | ||||
| AddUserBackuppc "${usr}" "${homebackuppc}" | ||||
| mkdir -p -- "${homebackuppc}"/.ssh | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création du répertoire .ssh de l'utilisateur : ${homebackuppc}/.ssh" | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Création du répertoire .ssh de l'utilisateur backuppc (${homebackuppc}/.ssh)" | ||||
| echo "from=\"129.20.203.16\" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIhMc8ixQXfWDACJy4q0v8T877UxahhCjO51PQFzylwVpf88LX3yWeDrWIW0NRu0zoSm396mig918OpD5ggqML/QbYbQsoDdAFUV/tK4JU6UJgEQIl25MOcUBCFepsFBGS09CH/V07xSUqSP/+beeTRLNO2CQzk3S2y3YfkXpM7KmOGfeLgoCaQAcxIkgLXeM3TpCZEzJDlZ8c8k/DjVvsgwCpQktYzNo2b37KHLLfgyW9KSo6N9sReUuNQjS6lu8rjrXfc6+J0pY2D6IxWptTWL/JVrhFCUqe4QQy+xYjoR41wqnAQyl/kOcyBNhSvojMKwQT6vlPwru6pOno16/X backuppc@backuppc.ipr.univ-rennes1.fr" > "${homebackuppc}"/.ssh/authorized_keys | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout de la clef SSH du serveur dans ${homebackuppc}/.ssh/authorized_keys" | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Ajout de la clef SSH du serveur dans (${homebackuppc}/.ssh/authorized_keys)." | ||||
| chown -R backuppc "${homebackuppc}"/.ssh/ | ||||
| [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : chown -R backuppc ${homebackuppc}/.ssh/" | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue