-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInstall.sh
More file actions
executable file
·258 lines (187 loc) · 6.89 KB
/
Copy pathInstall.sh
File metadata and controls
executable file
·258 lines (187 loc) · 6.89 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash
set -euf -o pipefail
source "InstallerFiles/Utils.sh"
noUpgrade=${1:-}
#########################
####### Functions #######
#########################
function copySystemDirectories() {
local destinationDir="$HOME/"
local sourceDir="SmartifyOS"
# Ensure destination path exists
mkdir -p "$destinationDir"
printBold "Copying system files..."
cp -a "$sourceDir" "$destinationDir"
}
function installInstallerDependencies() {
printBold "Updating your system..."
sudo apt-get update -y
if [ "$noUpgrade" != "no-upgrade" ]; then
sudo apt-get upgrade -y
fi
printBold "System updated"
}
function installDependencies() {
printBold "Installing dependencies..."
# Dependencies for media playback
sudo apt-get install -y pulseaudio-utils mpv
# Dependencies for bluetooth
sudo apt-get install -y rfkill pulseaudio-module-bluetooth
# Dependencies for touch input
sudo apt-get install -y python3-evdev python3-pynput
sudo apt-get install -y xinput
# Other dependencies
sudo apt-get install -y rsync
printBold "Dependencies installed"
}
function configureSudoers() {
printBold "Configuring sudoers..."
# Needed so the Unity app can run sudo commands
echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/$USER
sudo chmod 0440 /etc/sudoers.d/$USER
# Remove "$USER ALL = ALL" from /etc/sudoers, accounting for multiple spaces
sudo sed -i "/^$USER[[:space:]]\+ALL[[:space:]]\+=[[:space:]]\+ALL$/d" /etc/sudoers
if sudo visudo -c &>/dev/null; then
printBold "Sudoers configured successfully."
else
echo -e "${RED}Configuring sudoers failed. Rolling back changes.${RESET}"
sudo rm -f /etc/sudoers.d/$USER
exit 1
fi
# Other permissions
sudo usermod -a -G dialout $USER
}
function setPermissions() {
printBold "Setting permissions..."
find $HOME/SmartifyOS/ -name "*.sh" -exec chmod +x {} \;
sudo chmod +x "$HOME/SmartifyOS/GUI/SmartifyOS.x86_64"
}
addUdevUsbRule() {
local TOUCH_FILE=$1
local UDEV_RULE_FILE="/etc/udev/rules.d/99-touch-file-on-usb.rules"
# Check if the file path was provided
if [ -z "$TOUCH_FILE" ]; then
echo "Usage: addUdevRule <file-to-touch>"
return 1
fi
# Create the UDEV rule file with the necessary content
echo 'ACTION=="add", SUBSYSTEM=="usb", RUN+="/usr/bin/touch '$TOUCH_FILE'"' | sudo tee $UDEV_RULE_FILE > /dev/null
# Reload UDEV rules
sudo udevadm control --reload-rules
printBold "UDEV rule created and reloaded"
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function addStartupPrograms() {
printBold "Adding startup programs..."
addStartup "SmartifyOS" "$HOME/SmartifyOS/Scripts/StartSmartifyOS.sh"
}
function addUsbEvent() {
printBold "Adding USB event..."
addUdevUsbRule "$HOME/SmartifyOS/Events/OnUsbDeviceConnected"
}
function configureSystemSettings()
{
printBold "Configuring system settings..."
# Define the config file path
local CONFIG_FILE="/etc/lightdm/lightdm.conf"
# Define the lines to add
local pam_service="pam-service=lightdm"
local pam_autologin_service="pam-autologin-service=lightdm-autologin"
local autologin_user="autologin-user=$USER"
local autologin_timeout="autologin-user-timeout=0"
# Check if the file contains the "[Seat:*]" section
if grep -q "^\[Seat:\*\]" "$CONFIG_FILE"; then
echo "[Seat:*] section found, adding configurations..."
# Remove old lines if they already exist to prevent duplicates
sudo sed -i "/pam-service=lightdm/d" "$CONFIG_FILE"
sudo sed -i "/pam-autologin-service=lightdm-autologin/d" "$CONFIG_FILE"
sudo sed -i "/autologin-user=/d" "$CONFIG_FILE"
sudo sed -i "/autologin-user-timeout=/d" "$CONFIG_FILE"
# Add new configurations under "[Seat:*]"
sudo sed -i "/^\[Seat:\*\]/a $pam_service\n$pam_autologin_service\n$autologin_user\n$autologin_timeout" "$CONFIG_FILE"
else
echo "[Seat:*] section not found, creating it..."
# Append [Seat:*] section with the required lines
#echo -e "\n[Seat:*]\n$lines_to_add" >> "$CONFIG_FILE"
sudo echo -e "\n[Seat:*]\n$pam_service\n$pam_autologin_service\n$autologin_user\n$autologin_timeout" | sudo tee -a "$CONFIG_FILE" > /dev/null
fi
echo "Configurations added successfully."
# Replace /etc/default/grub with the new content
sudo tee /etc/default/grub > /dev/null << 'EOF'
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash gfxpayload=text loglevel=3 rd.systemd.show_status=auto rd.udev.log-priority=3 vt.global_cursor_default=0"
GRUB_CMDLINE_LINUX="console=ttyS0"
GRUB_BACKGROUND=""
EOF
sudo sed -i 's/^quiet_boot="0"/quiet_boot="1"/g' /etc/grub.d/10_linux
sudo systemctl mask getty@tty1.service
sudo update-grub
echo "Grub configuration updated successfully!"
sudo sed -i 's/^autorun=1/autorun=0/g' $HOME/.config/pcmanfm/LXDE/pcmanfm.conf
# Hide cursor
sudo sed -i -E 's|#xserver-command=X|xserver-command=X -nocursor|' "/etc/lightdm/lightdm.conf"
#sudo timedatectl set-ntp false
}
function configureAppearance() {
printBold "Configuring appearance..."
sudo sed -i 's/^@lxpanel --profile LXDE/#@lxpanel --profile LXDE/g' $HOME/.config/lxsession/LXDE/autostart
}
function setBackground() {
printBold "Setting background..."
local BACKGROUND_IMAGE="$SCRIPT_DIR/InstallerFiles/SmartifyOS-Background.png"
pcmanfm --set-wallpaper "$BACKGROUND_IMAGE"
sleep 0.5
sed -i 's/show_trash=1/show_trash=0/' $HOME/.config/pcmanfm/LXDE/desktop-items-0.conf
}
function askForReboot() {
read -p "Do you want to reboot now? (y/n): " RESPONSE
# Convert the response to lowercase
RESPONSE=$(echo "$RESPONSE" | tr '[:upper:]' '[:lower:]')
# Check the user's response
case "$RESPONSE" in
y|yes)
echo "Rebooting..."
sudo reboot
;;
n|no)
echo "Exiting..."
;;
*)
echo "Invalid response. Please enter 'y' or 'n'."
askForReboot
;;
esac
}
#########################
####### Installer #######
#########################
if ! checkInternet; then
echo "Please connect the Computer to the Internet while running the installer!"
exit 1
fi
#Install all dependencies need for the Installer
installInstallerDependencies
#Copy system files
copySystemDirectories
#Install all needed software
installDependencies
#Configure system permissions
configureSudoers
#Set permissions
setPermissions
#Add startup programs
addStartupPrograms
#Add USB event
addUsbEvent
#Configure system settings
configureSystemSettings
#Install gnome extension
configureAppearance
#set background
setBackground
source "InstallAdditions.sh"
#ask for reboot
askForReboot