emacs config remote backup and restore
This commit is contained in:
parent
4cbb0ee745
commit
fd7fda6c57
|
@ -90,11 +90,47 @@ function restore_local_emacs {
|
|||
}
|
||||
|
||||
function backup_remote_emacs {
|
||||
echo -n ''
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
||||
if [ -d /home/$USERNAME/.emacs.d ]; then
|
||||
echo $"Backing up Emacs config for $USERNAME"
|
||||
if [ -f /home/$USERNAME/.emacs ]; then
|
||||
cp /home/$USERNAME/.emacs /home/$USERNAME/.emacs.d/dotemacs
|
||||
fi
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /home/$USERNAME/.emacs.d emacs/$USERNAME
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function restore_remote_emacs {
|
||||
echo -n ''
|
||||
temp_restore_dir=/root/tempemacs
|
||||
if [ -d $USB_MOUNT/backup/emacs ]; then
|
||||
for d in $USB_MOUNT/backup/emacs/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
||||
if [ ! -d /home/$USERNAME ]; then
|
||||
${PROJECT_NAME}-adduser $USERNAME
|
||||
fi
|
||||
echo $"Restoring Emacs config for $USERNAME"
|
||||
function_check restore_directory_from_friend
|
||||
restore_directory_from_friend $temp_restore_dir emacs/$USERNAME
|
||||
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
|
||||
if [ ! "$?" = "0" ]; then
|
||||
rm -rf $temp_restore_dir
|
||||
function_check set_user_permissions
|
||||
set_user_permissions
|
||||
function_check backup_unmount_drive
|
||||
backup_unmount_drive
|
||||
exit 664
|
||||
fi
|
||||
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
|
||||
rm -rf $temp_restore_dir
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_emacs {
|
||||
|
|
Loading…
Reference in New Issue