From e067a9c717fe896033ab8a22ace998fda494867a Mon Sep 17 00:00:00 2001 From: Penelope Gwen Date: Thu, 30 May 2024 23:17:14 -0600 Subject: [PATCH] bug fix --- lib/sapphrc/sapphrc-filelists | 2 +- lib/sapphrc/sapphrc-functions | 12 ++++++------ lib/sapphrc/sapphrc-profile | 32 ++++++++++++++++---------------- lib/sapphrc/sapphrc-sync | 8 ++++---- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/sapphrc/sapphrc-filelists b/lib/sapphrc/sapphrc-filelists index 2c90d47..cd841a2 100644 --- a/lib/sapphrc/sapphrc-filelists +++ b/lib/sapphrc/sapphrc-filelists @@ -77,7 +77,7 @@ sapphrc_filelists(){ done validate_backupdir - validate_profile "${PROFILE}" + validate_profile "${PROFILE_NAME}" case "${OPERATION}" in add) diff --git a/lib/sapphrc/sapphrc-functions b/lib/sapphrc/sapphrc-functions index 439a6ca..27c9e08 100644 --- a/lib/sapphrc/sapphrc-functions +++ b/lib/sapphrc/sapphrc-functions @@ -35,27 +35,27 @@ check_name(){ } validate_profile(){ - profile_name="${1}" + PROFILE_NAME="${1}" first_check=true - while check_name "${profile_name}" "$first_check";do + while check_name "${PROFILE_NAME}" "$first_check";do first_check=false if [ "$COMMAND" == "create" ];then - read -p "Profile Name: " profile_name + read -p "Profile Name: " PROFILE_NAME else backups=( "${sapphrc_config}/backups/"* ) echo "$backups" if [ -d "${backups[0]}" ];then select d in $(ls "${sapphrc_config}/backups/");do test -n "$d" && break; echo ">>> Invalid Selection"; done - profile_name="$d" + PROFILE_NAME="$d" else echo "No backups exist!" exit 1 fi fi done - sapphrc_profile="${sapphrc_config}/backups/${profile_name}" + sapphrc_profile="${sapphrc_config}/backups/${PROFILE_NAME}" sapphrc_profile_rcdir="${sapphrc_profile}/home/.sapphrc" - sapphrc_profile_rc="${sapphrc_profile_rcdir}/${profile_name}" + sapphrc_profile_rc="${sapphrc_profile_rcdir}/${PROFILE_NAME}" } validate_backupdir(){ diff --git a/lib/sapphrc/sapphrc-profile b/lib/sapphrc/sapphrc-profile index 8320e3b..b031882 100644 --- a/lib/sapphrc/sapphrc-profile +++ b/lib/sapphrc/sapphrc-profile @@ -4,40 +4,40 @@ sapphrc_pcreate(){ mkdir -p "${sapphrc_profile_rcdir}" touch "${sapphrc_profile}/"{include,exclude} echo '#!/bin/bash'|tee "${sapphrc_profile_rc}" > /dev/null - echo ".sapphrc/${profile_name}"|tee "${sapphrc_profile}/include" > /dev/null + echo ".sapphrc/${PROFILE_NAME}"|tee "${sapphrc_profile}/include" > /dev/null chmod +x "${sapphrc_profile_rc}" - echo "Successfully created '${profile_name}'" - join "${profile_name}" + echo "Successfully created '${PROFILE_NAME}'" + sapphrc_join "${PROFILE_NAME}" } sapphrc_premove(){ - echo "WARNING: really remove profile '${profile_name}'?" + echo "WARNING: really remove profile '${PROFILE_NAME}'?" echo "~${sapphrc_profile#$HOME} and all its contents will be deleted!" read -p "Confirm removal (y/N): " confirm_remove if [[ "${confirm_remove}" =~ ^([yY][eE][sS]|[yY])$ ]];then - leave - echo "removing '${profile_name}'" + sapphrc_pleave + echo "removing '${PROFILE_NAME}'" rm -r "${sapphrc_profile}" - echo "Profile '${profile_name}' has been removed. Be sure to leave the profile on other machines/accounts to avoid synchronization issues." + echo "Profile '${PROFILE_NAME}' has been removed. Be sure to leave the profile on other machines/accounts to avoid synchronization issues." fi } sapphrc_pjoin(){ - if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then - echo "Already joined ${profile_name}, nothing to do." + if grep -q ^"${PROFILE_NAME}"$ "${sapphrc_config}/active_profiles";then + echo "Already joined ${PROFILE_NAME}, nothing to do." else - echo "${profile_name}"|tee -a "${sapphrc_config}/active_profiles" > /dev/null - echo "Successfully joined '${profile_name}'!" + echo "${PROFILE_NAME}"|tee -a "${sapphrc_config}/active_profiles" > /dev/null + echo "Successfully joined '${PROFILE_NAME}'!" fi } sapphrc_pleave(){ - if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then - sed -i '/^'"${profile_name}"'$/d' "${sapphrc_config}/active_profiles" - [ -e "${HOME}/.sapphrc/${profile_name}" ] && rm "${HOME}/.sapphrc/${profile_name}" - echo "Successfully left '${profile_name}'!" + if grep -q ^"${PROFILE_NAME}"$ "${sapphrc_config}/active_profiles";then + sed -i '/^'"${PROFILE_NAME}"'$/d' "${sapphrc_config}/active_profiles" + [ -e "${HOME}/.sapphrc/${PROFILE_NAME}" ] && rm "${HOME}/.sapphrc/${PROFILE_NAME}" + echo "Successfully left '${PROFILE_NAME}'!" else - echo "You have not joined '${profile_name}', nothing to do." + echo "You have not joined '${PROFILE_NAME}', nothing to do." fi } diff --git a/lib/sapphrc/sapphrc-sync b/lib/sapphrc/sapphrc-sync index 23fb124..29a0059 100644 --- a/lib/sapphrc/sapphrc-sync +++ b/lib/sapphrc/sapphrc-sync @@ -4,11 +4,11 @@ sapphrc_rsync(){ echo "" # validate_backupdir sync_direction="$1" - cat "${sapphrc_config}/active_profiles" | while read profile_name + cat "${sapphrc_config}/active_profiles" | while read PROFILE_NAME do - backup_homedir="$sapphrc_config/backups/${profile_name}/home" - include_list="$sapphrc_config/backups/${profile_name}/include" - exclude_list="$sapphrc_config/backups/${profile_name}/exclude" + backup_homedir="$sapphrc_config/backups/${PROFILE_NAME}/home" + include_list="$sapphrc_config/backups/${PROFILE_NAME}/include" + exclude_list="$sapphrc_config/backups/${PROFILE_NAME}/exclude" case ${sync_direction} in backup) echo "backup"