Remove more bashism. master
authorSebastian Pohle <sepohle@math.uni-paderborn.de>
Fri, 2 Sep 2011 18:11:17 +0000 (20:11 +0200)
committerMaximilian Wilhelm <max@rfc2324.org>
Fri, 2 Sep 2011 18:11:17 +0000 (20:11 +0200)
ACKed-by: Maximilian Wilhelm <max@rfc2324.org>

files/client/ssh-keysync
files/server/ssh-keysync-adddomain
files/server/upgrade_sshkeysync

index 4ad7cd8..caf67df 100755 (executable)
@@ -38,8 +38,8 @@ die()
 # Check if the config file exist and load options if possbile
 check_config()
 {
-       if [ -f "${CONFIG_FILE}" -a -r "${CONFIG_FILE}" ]; then
-               if ! source "${CONFIG_FILE}"; then
+       if [ -f "${CONFIG_FILE}" ] && [ -r "${CONFIG_FILE}" ]; then
+               if ! . "${CONFIG_FILE}"; then
                        echo "Failed to load config file \"${CONFIG_FILE}\", exiting." >&2
                        exit 1
                fi
@@ -93,7 +93,7 @@ check_server()
 
 # Get global ssh_known_hosts from the server
 pull() {
-       [ "${debug}" ] && echo -n "Getting global key file from the server: "
+       [ "${debug}" ] && printf "Getting global key file from the server: "
 
        if [ check_server ]; then
                FILE=`basename "${SERVER_PATH}"`
index c19d947..4ed79bd 100755 (executable)
@@ -44,7 +44,7 @@ DEBUG=""
 
 ##
 # usage(): Print a nice little usage text      # {{{
-function usage() {
+usage() {
 cat << EOUSAGE >&2
 Usage: $0 [-sof | -nsof] [-cof | -nsof] my.dom.ain [myalt.dom.ain [...]]
 
@@ -62,7 +62,7 @@ EOUSAGE
 
 ##
 # handle_domain(): Handle given domain the right way   # {{{
-function handle_domain() {
+handle_domain() {
        if [ "$#" = 1 ]; then
                if [ -z "${DOMAIN}" ]; then
                        DOMAIN="$1"
@@ -144,13 +144,13 @@ if [ -d "${BASE_DIR}/${DOMAIN}" ]; then
 fi
 
 # If config entry *and* directory exist, eveyrthing is fine.
-if [ "${DOM_CONFIG}" -a "${DOM_DIR}" ]; then
+if [ "${DOM_CONFIG}" ] && [ "${DOM_DIR}" ]; then
        echo "Domain ${DOMAIN} allready configured properly." >&2
        exit 0
 fi
 
 # If we're still running and one of the following is set, that's not good.
-if [ "${DOM_CONFIG}" -o "${DOM_DIR}" ]; then
+if [ "${DOM_CONFIG}" ] || [ "${DOM_DIR}" ]; then
        echo "Giving up, you have to fix this situation manually..." >&2
        exit 1
 fi
index f6b33fd..ac6403b 100755 (executable)
@@ -7,18 +7,18 @@ CONFIG_OLD="${CONFIGFILE}.oldsave"
 
 ##
 # upgrade_config(): Upgrade the configuration file #{{{
-function upgrade_config() {
+upgrade_config() {
 
        echo "=========="
        echo "Upgrading Configuration file ${CONFIGFILE}... "
 
        if ! grep -q '\[general\]' "${CONFIGFILE}"; then
 
-               echo -n " * Moving old file to ${CONFIG_OLD}... "
+               printf " * Moving old file to ${CONFIG_OLD}... "
                mv "${CONFIGFILE}" "${CONFIG_OLD}" && echo "done." || echo "Failed!"
 
-               if [ -f ${CONFIGOLD} -a -r ${CONFIG_OLD} ]; then
-                       if ! source "${CONFIG_OLD}" ; then
+               if [ -f ${CONFIGOLD} ] && [ -r ${CONFIG_OLD} ]; then
+                       if ! . "${CONFIG_OLD}" ; then
                                echo "Failed to load config file \"${CONFIG_OLD}\", exiting." >&2
                                exit 1
                        fi
@@ -44,7 +44,7 @@ function upgrade_config() {
                EXPR_USER="s|^user.*|user = ${VALID_USER}|"
                EXPR_BASEDIR="s|^base_dir.*|base_dir = ${BASE_DIR}|"
 
-               echo -n "Writing new config... "
+               printf "Writing new config... "
                cat << EOF | sed -e "${EXPR_USER}" -e "${EXPR_BASEDIR}" > "${CONFIGFILE}" && echo "done." || echo "Failed!"
 #
 # /etc/ssh-keysync/ssh-keysync-server.conf
@@ -96,15 +96,15 @@ EOF
 
 ##
 # upgrade_dirs(): Upgrade the filesystem structure #{{{
-function upgrade_dirs() {
+upgrade_dirs() {
        echo "=========="
        echo "Upgrade file system structure:"
 
        # Check for old style config
        if ! grep -q '\[general\]' "${CONFIGFILE}"; then
 
-               if [ -f ${CONFIG_FILE} -a -r ${CONFIG_FILE} ]; then
-                       if ! source "${CONFIGFILE}" ; then
+               if [ -f ${CONFIG_FILE} ] && [ -r ${CONFIG_FILE} ]; then
+                       if ! . "${CONFIGFILE}" ; then
                                echo "Failed to load config file \"${CONFIGFILE}\", exiting." >&2
                                exit 1
                        fi
@@ -137,10 +137,10 @@ function upgrade_dirs() {
 
        # Go for it
        if [ -d "${BASE_DIR}/keys" ]; then
-               echo -n " * Creating domain directory: ${BASE_DIR}/${DOMAIN} ... "
+               printf " * Creating domain directory: ${BASE_DIR}/${DOMAIN} ... "
                mkdir -p "${BASE_DIR}/${DOMAIN}" && echo "done." || echo "Failed!"
 
-               echo -n " * Moving ${BASE_DIR}/keys to ${BASE_DIR}/${DOMAIN}/keys... "
+               printf " * Moving ${BASE_DIR}/keys to ${BASE_DIR}/${DOMAIN}/keys... "
                mv "${BASE_DIR}/keys" "${BASE_DIR}/${DOMAIN}" && echo "done." || echo "Failed!"
        else
                echo " No old style key dir found. Nothing to do for me."