-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutility.sh
executable file
·82 lines (74 loc) · 2.2 KB
/
utility.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Author: 33
function start {
# Check desktop manager type
# TODO:
# Support more Desktop managers.
# Currently supports cinnamon only
if [ "$XDG_CURRENT_DESKTOP" == "X-Cinnamon" ]; then
#validating inputs
case $1 in
backup)
if [ ! -d "$2" ]; then
echo ""
echo -e "Invalid directory path"
echo -e "Please re-run the script with valid path"
echo -e "Exiting script.."
exit 3
else
echo ""
echo "### backup started ###"
./$XDG_CURRENT_DESKTOP.sh $1 $2
fi
;;
restore)
if ! gzip -t "$2"; then
echo ""
echo -e "Invalid backup file"
echo -e "Please re-run the script with valid backup file"
echo -e "Exiting script.."
exit 4
else
echo ""
echo "### Restoring ###"
./$XDG_CURRENT_DESKTOP.sh $1 $2
fi
;;
esac
else
echo ""
echo -e "Sorry! This utility is only for cinnamon Desktop"
echo -e "You're using '$XDG_CURRENT_DESKTOP'"
echo -e "Exiting script.."
exit 1
fi
exit 0
}
function dependencies {
# check if gzip is installed
if ! type -p "gzip" >/dev/null; then
echo "################################################################"
echo " installing missing dependencies for this script to work"
echo "#################################################################"
sudo apt-get install -y gzip
clear
fi
}
# Script starting point
####################################################################################
# Print help in case parameters are empty
if [ $# != 2 ] || [ "$1" != "backup" ] && [ "$1" != "restore" ]; then
echo ""
echo -e "Usage: $0 [command] path to backup [options]"
echo ""
echo -e "Commands:"
echo -e " backup - Backup entire cinnamon desktop settings"
echo -e " restore - Restore entire cinnamon desktop settings"
echo -e "Options:"
echo -e " Path should be a directory to store the backup file if you are backuping"
echo -e " Path of the backup file if you are restoring"
exit 2
else
dependencies
start $1 $2
fi