#!/bin/bash CONF=/etc/config/qpkg.conf QPKG_NAME="HybridBackup" QPKG_INSTALL_PATH=$(/sbin/getcfg $QPKG_NAME Install_Path -d FALSE -f $CONF) HBS_TM_CONF="${QPKG_INSTALL_PATH}/timemachine.conf" function is_afpd_running() { /bin/ps | /bin/grep "sbin/afpd" | /bin/grep -v grep > /dev/null 2>&1 afp_exist=$? if [ "${afp_exist}" = "0" ]; then return 0 # true else return 1 # false fi } function is_smbd_running() { /bin/ps | /bin/grep "sbin/smbd" | /bin/grep -v grep > /dev/null 2>&1 smb_exist=$? if [ "${smb_exist}" = "0" ]; then return 0 # true else return 1 # false fi } function migrate() { _tmp_conf="${HBS_TM_CONF}.migrae.tmp" _old_tm_enabled=$(/sbin/getcfg "TimeMachine" Enabled -u -d FALSE) echo "[Global]" > "${_tmp_conf}" if [ "${_old_tm_enabled}" = "TRUE" ]; then echo "Enable = TRUE" >> "${_tmp_conf}" else echo "Enable = FALSE" >> "${_tmp_conf}" fi if is_smbd_running; then echo "BonjourSMB = TRUE" >> "${_tmp_conf}" else echo "BonjourSMB = FALSE" >> "${_tmp_conf}" fi if [ "${_old_tm_enabled}" = "TRUE" ]; then if is_afpd_running; then echo "BonjourAFP = TRUE" >> "${_tmp_conf}" else echo "BonjourAFP = FALSE" >> "${_tmp_conf}" fi else # whole new install that default disable bonjour afp echo "BonjourAFP = FALSE" >> "${_tmp_conf}" fi echo "[SharedAccount]" >> "${_tmp_conf}" if [ "${_old_tm_enabled}" = "TRUE" ]; then echo "Enable = TRUE" >> "${_tmp_conf}" else echo "Enable = FALSE" >> "${_tmp_conf}" fi echo "UserName = TimeMachine" >> "${_tmp_conf}" echo "FolderName = TMBackup" >> "${_tmp_conf}" _capacity=$(/sbin/getcfg "TimeMachine" "Capacity" -u -d "0") echo "CapacityGB = ${_capacity}" >> "${_tmp_conf}" mv "${_tmp_conf}" "${HBS_TM_CONF}" /bin/chmod 644 "${HBS_TM_CONF}" } case "$1" in migrate) migrate ;; *) echo "Not support [$1]" echo "Usage: $0 {migrate}" exit 1 esac exit 0