-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.sh
More file actions
executable file
·142 lines (107 loc) · 2.95 KB
/
system.sh
File metadata and controls
executable file
·142 lines (107 loc) · 2.95 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
# Check script.log for error logs. Pipefail set. No clobber set.
set -Eeuo pipefail
set -o noclobber
# exec >script.log 2>&1
exec 2>script.log
echo -e "\nThis error log is generated by system.sh\n" >&2
# Enable Bluetooth service.
sudo systemctl enable bluetooth.service
sudo systemctl start bluetooth.service
# Configure Pacman.
cat /etc/pacman.conf
sudo vim /etc/pacman.conf
# Mount /dev/sda1 using fstab
sudo tee -a /etc/fstab < /run/media/DATA/SOFTWARE/Linux/DOTFILES/etc/fstab
sudo mkdir -p /media/DATA /media/SAFE /media/STORM
# # If using windows:
# sudo mkdir -p /media/WINDOWS
sudo chown -R devlinman:devlinman /media
sudo umount /dev/sda1
sudo systemctl daemon-reload
sudo mount -a
# Disable this sevice for optimized boot times.
sudo systemctl disable systemd-networkd-wait-online.service
# ownership of sddm config
sudo chown -R sddm:sddm /var/lib/sddm/.config
# Create User Image.
# sudo cp ./config/devlinman.png /var/lib/AccountsService/icons/$USER
sudo cp ./config/devlinman.png /var/lib/AccountsService/icons/devlinman
# Copy konsave config file.
cp /media/DATA/SOFTWARE/Linux/DOTFILES/home/devlinman/.config/konsave/conf.yaml ~/.config/konsave/conf.yaml
# Create symlinks for Home folders.
HOME_DIR="$HOME"
# ---- Directory list ----
DIRS=(
Applications
Desktop
Documents
Downloads
Music
Pictures
Templates
Vaults
Videos
)
# ---- Destination mappings ----
# Default: /media/DATA/<DirName>
# Exceptions handled explicitly
declare -A DEST_MAP=(
[Applications]="/media/DATA/SOFTWARE/Linux/Applications"
[Desktop]="/media/DATA/Desktop"
[Documents]="/media/DATA/Documents"
[Downloads]="/media/Downloads"
[Music]="/media/DATA/Music"
[Pictures]="/media/DATA/Pictures"
[Templates]="/media/DATA/Templates"
[Vaults]="/media/DATA/Vaults"
[Videos]="/media/DATA/Videos"
)
echo "==> Checking directory existence in ~"
missing_dirs=()
for dir in "${DIRS[@]}"; do
if [[ ! -d "$HOME_DIR/$dir" ]]; then
missing_dirs+=("$dir")
fi
done
if (( ${#missing_dirs[@]} > 0 )); then
echo "ERROR: Missing directories in ~:"
for d in "${missing_dirs[@]}"; do
echo " - $d"
done
exit 1
fi
echo "All directories exist"
echo
echo "==> Checking that directories are empty"
non_empty_dirs=()
for dir in "${DIRS[@]}"; do
if [[ -n "$(ls -A "$HOME_DIR/$dir")" ]]; then
non_empty_dirs+=("$dir")
fi
done
if (( ${#non_empty_dirs[@]} > 0 )); then
echo "ERROR: The following directories are NOT empty:"
for d in "${non_empty_dirs[@]}"; do
echo
echo "Contents of ~$d:"
ls -A "$HOME_DIR/$d"
done
exit 1
fi
echo "All directories are empty"
echo
echo "==> Replacing directories with symlinks"
for dir in "${DIRS[@]}"; do
src="$HOME_DIR/$dir"
dest="${DEST_MAP[$dir]}"
if [[ -z "$dest" ]]; then
echo "ERROR: No destination defined for $dir"
exit 1
fi
echo "Linking ~$dir -> $dest"
rmdir "$src"
ln -s "$dest" "$src"
done
echo
echo "All directories successfully replaced with symlinks"