-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15-user_preference.sh
More file actions
executable file
·77 lines (67 loc) · 2.46 KB
/
15-user_preference.sh
File metadata and controls
executable file
·77 lines (67 loc) · 2.46 KB
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
#!/bin/bash
DIT_HOME="/home/ditrobotics"
# Check if the current user is root
if [ "$(id -u)" != "0" ]; then
echo -e "This script must be run as root. \nPlease run again with 'sudo $0'"
exit 1
fi
# Restore firefox configuration
restore_firefox() {
echo -e "\033[32mRestoring firefox user preference...\033[0m"
# You need to open firefox first to create the folder
read -p "Please open firefox first. Press [Enter] key to continue..."
if [ -d "$DIT_HOME/snap/firefox/common/.mozilla/firefox/" ]; then
rm -rf "$DIT_HOME/snap/firefox/common/.mozilla/firefox/"
fi
mkdir -p "$DIT_HOME/snap/firefox/common/.mozilla/firefox/"
tar -xzf "$DIT_HOME/DIT-Scripts/.config/firefox/firefox_profile_backup.tar.gz" -C "$DIT_HOME/snap/firefox/common/.mozilla/firefox/"
chown -R ditrobotics:ditrobotics "$DIT_HOME/snap/firefox/common/.mozilla/firefox/"
chmod -R 700 "$DIT_HOME/snap/firefox/common/.mozilla/firefox/"
}
# Restore desktop configuration
restore_desktop() {
echo -e "\033[32mRestoring desktop user preference...\033[0m"
cp -r "$DIT_HOME/DIT-Scripts/desktop/"* "$DIT_HOME/Desktop/"
if [ ! -d /home/share/scripts/ ]; then
mkdir -p /home/share/scripts/
fi
cp -r "$DIT_HOME/DIT-Scripts/share/scripts/"* /home/share/scripts/
if [ ! -d /home/share/data/ ]; then
mkdir -p /home/share/data/
fi
cp -r "$DIT_HOME/DIT-Scripts/share/data/"* /home/share/data/
# Ensure the share folder is accessible for every user in the docker group
chgrp -R docker /home/share
chmod -R g+rw /home/share
chmod -R 666 /home/share/data/*
}
# Restore plymouth theme configuration
restore_plymouth() {
echo -e "\033[32mRestoring plymouth theme preference...\033[0m"
cp -r "$DIT_HOME/DIT-Scripts/system/plymouth-themes/abstract_ring_alt" /usr/share/plymouth/themes/
update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/abstract_ring_alt/abstract_ring_alt.plymouth 100
echo -e "\033[32mSelect the number for installed theme...\033[0m"
update-alternatives --config default.plymouth
update-initramfs -u
}
if [ "$1" == "all" ]; then
restore_firefox
restore_desktop
restore_plymouth
else
case "$1" in
firefox)
restore_firefox
;;
desktop)
restore_desktop
;;
plymouth)
restore_plymouth
;;
*)
echo "Usage: $0 {all|firefox|desktop|plymouth}"
exit 1
;;
esac
fi