diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2012-06-28 13:00:35 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2012-06-28 13:00:35 -0300 |
commit | 2fd48674cb047738c0ba5a33872f68898cc89f4e (patch) | |
tree | 7e98ddf2382d12fa7e26601c061dab2e5a64cf32 | |
parent | ee097d06907795bc4b17b231274ad88479cc6bc2 (diff) | |
download | hydra-2fd48674cb047738c0ba5a33872f68898cc89f4e.tar.gz hydra-2fd48674cb047738c0ba5a33872f68898cc89f4e.tar.bz2 |
Cleanup at backup-restore-hidden
-rwxr-xr-x | share/hydractl/backup-restore-hidden | 53 |
1 files changed, 15 insertions, 38 deletions
diff --git a/share/hydractl/backup-restore-hidden b/share/hydractl/backup-restore-hidden index 4e2ba2a..d439b29 100755 --- a/share/hydractl/backup-restore-hidden +++ b/share/hydractl/backup-restore-hidden @@ -22,59 +22,36 @@ hydra_config_load # Parameters. DATE="`date +%Y%m%d`" -HIDDEN_DIR="/var/lib/tor/hidden" +HOST="$1" +SERVICE="hidden" +SERVICE_DIR="/var/lib/tor/hidden" +SERVICE_USER="debian-tor" +SERVICE_GROUP="debian-tor" -# Check restore strategy. -if [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then - hydra_backup_environment_local -else - hydra_backup_environment_remote $1 restore -fi - -# Check if folder exist on the backup. -if [ ! -d "$RESTOREDIR/$HIDDEN_DIR" ]; then - echo "Hidden services folder does not exist: $RESTOREDIR/$HIDDEN_DIR" - exit 1 -fi - -# Set git user. -if hydra_check_user debian-tor; then - HIDDEN_USER="debian-tor" -else - HIDDEN_USER="root" -fi - -# Set git group. -if hydra_check_group debian-tor; then - HIDDEN_GROUP="debian-tor" -else - HIDDEN_GROUP="root" -fi - -# TODO: Backup it? -#hydractl backup-hidden +# Set restore environment. +hydra_backup_environment_service # Restore hidden service folder from backup. # # Symlink creation on site instances like drupal should be done # already by backup-restore-site. -for folder in `ls $RESTOREDIR/$HIDDEN_DIR`; do - if [ -e "$HIDDEN_DIR/$folder/hostname" ]; then +for folder in `ls $RESTOREDIR/$SERVICE_DIR`; do + if [ -e "$SERVICE_DIR/$folder/hostname" ]; then # A hidden service already exists - if ! diff "$HIDDEN_DIR/$folder/hostname" "$RESTOREDIR/$HIDDEN_DIR/$folder/hostname" &> /dev/null; then + if ! diff "$SERVICE_DIR/$folder/hostname" "$RESTOREDIR/$SERVICE_DIR/$folder/hostname" &> /dev/null; then # They're different hidden services! - echo "Hidden service $hidden already exists on $HIDDEN_DIR/$folder and differs from backup!" + echo "Hidden service $hidden already exists on $SERVICE_DIR/$folder and differs from backup!" echo "Please fix this conflict manually and restore backups again." else echo "Hidden service $hidden already in place, no need to copy." fi else - echo "Processing $HIDDEN_DIR/$folder..." - rm -rf $HIDDEN_DIR/$folder - cp -a $RESTOREDIR/$HIDDEN_DIR/$folder $HIDDEN_DIR/$folder + echo "Processing $SERVICE_DIR/$folder..." + rm -rf $SERVICE_DIR/$folder + cp -a $RESTOREDIR/$SERVICE_DIR/$folder $SERVICE_DIR/$folder fi done # Fix permissions. -chown -R $HIDDEN_USER.$HIDDEN_GROUP $HIDDEN_DIR +chown -R $SERVICE_USER.$SERVICE_GROUP $SERVICE_DIR |