From c21a8957476f2aec884c0f718db86bc54ec7f91c Mon Sep 17 00:00:00 2001 From: GARDAIS Jeremy Date: Thu, 26 Apr 2018 14:54:30 +0200 Subject: [PATCH] Fix DEBUG messages indentation --- install_backuppc_mac.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/install_backuppc_mac.sh b/install_backuppc_mac.sh index 42749ee..85e1758 100755 --- a/install_backuppc_mac.sh +++ b/install_backuppc_mac.sh @@ -24,7 +24,7 @@ function AllowUserToConnectToThisMachineUsingSsh() userLogin="$1" 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}." + [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Autoriser les accès SSH pour ${userLogin}." } ## }}} @@ -32,7 +32,7 @@ function AllowUserToConnectToThisMachineUsingSsh() 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)." + [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Désactivation du mode furtif (ping)." if [ $? != 0 ]; then printf '\e[1;31m%-6s\e[m\n' "ERREUR : La désactivation du mode furtif a échoué" return "$ERROR" @@ -44,14 +44,14 @@ function EnsurePingIsAllowed() 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." + [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Vérification si sshd est déjà en cours." 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." + [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : Activation du serveur ssh." if [ $? != 0 ]; then printf '\e[1;31m%-6s\e[m\n' "ERREUR : L'activation du serveur ssh a échoué"; return "$ERROR" @@ -141,11 +141,11 @@ 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}." + [[ "${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" + [[ "${DEBUG}" == "0" ]] && printf '\e[1;33m%-6s\e[m\n' "DEBUG : chown -R $userLogin:$groupId $homeDir" AllowUserToConnectToThisMachineUsingSsh "${userLogin}" @@ -164,7 +164,7 @@ function AllowBackuppcSudo() { printf '%b\n' "Configuration de sudo pour BackupPC." else 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." + [[ "${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 de ${sudoersDir} dans le fichier sudoers." fi else printf '\e[1;31m%-6s\e[m\n' "ERREUR : Impossible de trouver un fichier de configuratio pour sudo." @@ -313,6 +313,7 @@ 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}" 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"