diff --git a/install_backuppc_mac.sh b/install_backuppc_mac.sh index 2c2fb74..800ac25 100755 --- a/install_backuppc_mac.sh +++ b/install_backuppc_mac.sh @@ -20,7 +20,8 @@ function GetDefaultUser() { # this performs the equivalent as adding a remote login user in system preferences using the gui function AllowUserToConnectToThisMachineUsingSsh() { - local userLogin="$1" + local userLogin + 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}." @@ -74,7 +75,8 @@ function GetMyHostKey() { ## IpAddress {{{ function IpAddress() { - local strMyIpAddress='' + local strMyIpAddress + strMyIpAddress='' strMyIpAddress=$(dig +short myip.opendns.com @resolver1.opendns.com) if [ "${strMyIpAddress}" == '' ]; then error "failed to retrieve the ip address of this machine" @@ -86,15 +88,18 @@ function IpAddress() { ## MyFqdn {{{ function MyFqdn() { - local strMyIpAddress=$( IpAddress ) # eg '129.20.27.49' - local strMyFqdn=$(host "${strMyIpAddress}" | awk '{print $5}') + local strMyIpAddress + local strMyFqdn + strMyIpAddress=$( IpAddress ) # eg '129.20.27.49' + strMyFqdn=$(host "${strMyIpAddress}" | awk '{print $5}') echo "${strMyFqdn%?}" # remove the trailing '.' } ## }}} ## ListUsers {{{ function ListUsers() { - local users='' + local users + users='' for user in $(ls -d /Users/[a-zA-Z]*); do user=$(basename "${user}") case "${user}" in @@ -111,10 +116,14 @@ function ListUsers() { ## AddUserBackuppc {{{ function AddUserBackuppc() { - local userToBackup="$1" # the login of the user to backup - local homeDir="$2" # eg. '/var/lib/backuppc' - local userLogin='backuppc' - local groupId=$(id -g "${userToBackup}") + local userToBackup + local homeDir + local userLogin + local groupId + userToBackup="$1" # the login of the user to backup + homeDir="$2" # eg. '/var/lib/backuppc' + userLogin='backuppc' + groupId=$(id -g "${userToBackup}") maxid=$(dscl . -list /Users UniqueID | awk '$2 < 1000 {print $2}' | sort -ug | tail -1) newid=$((maxid+1)) mkdir -p "$homeDir" @@ -147,9 +156,10 @@ function AddUserBackuppc() { ## AllowBackuppcSudo {{{ function AllowBackuppcSudo() { # Get sudoers directory from the configuration - local sudoersDir=$(grep "^#includedir " /etc/sudoers | cut -d" " -f2) + local sudoersDir + sudoersDir=$(grep "^#includedir " /etc/sudoers | cut -d" " -f2) if [ -f /etc/sudoers ]; then - local sudoersDir=$(grep "^#includedir " /etc/sudoers | cut -d" " -f2) + sudoersDir=$(grep "^#includedir " /etc/sudoers | cut -d" " -f2) if [ ! "${sudoersDir}" == '' ]; then printf '%b\n' "Configuration de sudo pour BackupPC." else @@ -157,7 +167,7 @@ function AllowBackuppcSudo() { [[ "${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 - local sudoersDir=$(grep "^#includedir " /private/etc/sudoers | cut -d" " -f2) + sudoersDir=$(grep "^#includedir " /private/etc/sudoers | cut -d" " -f2) if [ ! "${sudoersDir}" == '' ]; then printf '%b\n' "Configuration de sudo pour BackupPC." else