-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·187 lines (165 loc) · 5.82 KB
/
setup.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
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
#!/bin/bash
# Function to detect the operating system distribution
get_distribution() {
if [ "$(cat /proc/cpuinfo | egrep -i "raspberry pi")" != "" ]; then
echo "raspbian"
elif [ -f /etc/os-release ]; then
. /etc/os-release
echo "$ID"
else
echo "unknown"
fi
}
# Get the distribution
DISTRO=$(get_distribution)
# Function to print the current step
log_step() {
echo "Step $1: $2"
}
# Update the system
log_step 1 "Updating the Operating System..."
if [ "$DISTRO" == "raspbian" ] || [ "$DISTRO" == "debian" ]; then
sudo apt-get update
sudo apt-get full-upgrade -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
else
echo "Unsupported distribution: $DISTRO"
exit 1
fi
# Install necessary packages based on the distribution
log_step 2 "Installing a Minimal Desktop Environment, Git, Firefox, ImageMagick, and feh..."
if [ "$DISTRO" == "raspbian" ] || [ "$DISTRO" == "debian" ]; then
sudo apt-get install -y lightdm openbox git xterm firefox-esr plymouth plymouth-themes imagemagick feh freerdp2-x11 python3 python3-pyqt5 python3-pyqt5.*
else
echo "Unsupported distribution: $DISTRO"
exit 1
fi
# Clone or update the PyRDPConnect repository
log_step 3 "Cloning or updating the PyRDPConnect repository..."
if [ -d "~/PyRDPConnect" ]; then
cd ~/PyRDPConnect
git pull
cd ~
else
cd ~
git clone https://github.com/LaswitchTech/PyRDPConnect.git
fi
# Create a gradient background image
log_step 4 "Creating a gradient background image..."
mkdir -p ~/backgrounds
convert -size 1920x1080 gradient:'#265162-#002136' ~/backgrounds/gradient.png
# Configure Openbox
log_step 5 "Configuring Openbox to start without panels, set the gradient background, and customize the menu..."
mkdir -p ~/.config/openbox
# Autostart and menu configurations
cat <<EOL > ~/.config/openbox/autostart
# Set gradient background
feh --bg-scale ~/backgrounds/gradient.png &
# Autostart PyRDPConnect in full-screen mode
python3 ~/PyRDPConnect/src/PyRDPConnect.py &
EOL
cat <<EOL > ~/.config/openbox/menu.xml
<openbox_menu>
<menu id="root-menu" label="Openbox Menu">
<item label="PyRDPConnect">
<action name="Execute">
<command>python3 ~/PyRDPConnect/src/PyRDPConnect.py</command>
</action>
</item>
<item label="Terminal">
<action name="Execute">
<command>xterm</command>
</action>
</item>
<item label="Web Browser">
<action name="Execute">
<command>firefox</command>
</action>
</item>
<item label="Restart">
<action name="Execute">
<command>systemctl reboot</command>
</action>
</item>
<item label="Shutdown">
<action name="Execute">
<command>systemctl poweroff</command>
</action>
</item>
</menu>
</openbox_menu>
EOL
# Set Openbox to start automatically
log_step 6 "Setting Openbox to start automatically..."
cat <<EOL > ~/.xinitrc
exec openbox-session
EOL
# Set locale and timezone
log_step 7 "Setting locale and timezone..."
sudo sed -i '/en_GB.UTF-8/s/^/#/' /etc/locale.gen
sudo sed -i '/en_CA.UTF-8/s/^# //g' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=en_CA.UTF-8
sudo timedatectl set-timezone America/Toronto
# Configure PolicyKit for non-sudo reboot and shutdown
log_step 8 "Configuring PolicyKit for non-sudo reboot/shutdown..."
sudo bash -c 'cat <<EOL > /etc/polkit-1/localauthority/50-local.d/10-power-management.pkla
[Allow Reboot and Shutdown]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot;org.freedesktop.login1.power-off
ResultActive=yes
EOL'
# Disable verbose boot and enable Plymouth theme
log_step 9 "Disabling verbose boot and enabling Plymouth theme..."
if [ -f "/boot/firmware/cmdline.txt" ]; then
FILE=/boot/firmware/cmdline.txt
sudo sed -i 's/console=tty1/console=tty3 splash quiet plymouth.ignore-serial-consoles/' $FILE
if ! grep -q "splash quiet" $FILE; then
echo "splash quiet" | sudo tee -a $FILE
fi
sudo bash -c "echo "disable_splash=1" >> $FILE"
fi
# Copy and set custom Plymouth theme
log_step 10 "Setting the custom Plymouth theme..."
if [ -d "/usr/share/plymouth/themes/pyrdpconnect" ]; then
sudo rm -rf /usr/share/plymouth/themes/pyrdpconnect
fi
sudo cp -r ~/PyRDPConnect/src/plymouth /usr/share/plymouth/themes/pyrdpconnect
sudo plymouth-set-default-theme -R pyrdpconnect
sudo update-initramfs -u
# Enable auto-login for Debian
if [ "$DISTRO" == "debian" ]; then
log_step 11 "Enabling auto-login for Debian..."
if grep -q "^#autologin-user=" /etc/lightdm/lightdm.conf; then
sudo sed -i "s/^#autologin-user=.*/autologin-user=$USER/" /etc/lightdm/lightdm.conf
else
echo "autologin-user=$USER" | sudo tee -a /etc/lightdm/lightdm.conf
fi
if grep -q "^#autologin-user-timeout=" /etc/lightdm/lightdm.conf; then
sudo sed -i "s/^#autologin-user-timeout=.*/autologin-user-timeout=0/" /etc/lightdm/lightdm.conf
else
echo "autologin-user-timeout=0" | sudo tee -a /etc/lightdm/lightdm.conf
fi
fi
# Additional Raspberry Pi OS-specific configurations
if [ "$DISTRO" == "raspbian" ]; then
log_step 12 "Configuring Raspberry Pi OS for desktop boot and multi-monitor support..."
# Set up Raspberry Pi to boot into the desktop environment
sudo raspi-config nonint do_boot_behaviour B4
if [ "$(echo "./setup --multimon" | grep -- --multimon)" != "" ]; then
# Enable HDMI output for both monitors
sudo bash -c 'cat <<EOL >> /boot/config.txt
# Enable HDMI output for both monitors
hdmi_force_hotplug=1
hdmi_force_hotplug:1=1
hdmi_group=2
hdmi_mode=82
hdmi_group:1=2
hdmi_mode:1=82
disable_overscan=1
EOL'
fi
fi
# Final instructions
log_step 13 "Setup completed. Please reboot the system to apply the changes."