-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
182 lines (157 loc) · 5.16 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
#!/bin/sh
# _ _ ___ _ _
# __ _| | _____ _____ ___ __| | ___ _ __ / _ \| || |
# / _` | |/ _ \ \/ / __/ _ \ / _` |/ _ \ '__| | | | || |_
# | (_| | | __/> < (_| (_) | (_| | __/ | | |_| |__ _|
# \__,_|_|\___/_/\_\___\___/ \__,_|\___|_| \___/ |_|
#
# Copyright (c) 2021-2022 alexcoder04 <https://github.com/alexcoder04>
#
# setting up raspberry pi (on RaspberryPi OS)
#
# TODO setup doas
_VERSION="0.1.0"
PACKAGES_TO_REMOVE="geany thonny lxtask"
PACKAGES_REQUIRED="git make"
PACKAGES_TO_INSTALL="
w3m cmatrix neovim zsh"
PACKAGES_GRAPHICAL="
i3 i3blocks rofi feh
lxappearance arc-theme papirus-icon-theme fonts-font-awesome"
DEFAULT_DOTFILES_REPO="https://github.com/alexcoder04/dotfiles"
die(){
echo "---------------------------------------------------"
echo "ERROR: $1"; exit 1
}
yesno_continue(){
printf "${1:-Do you want to continue [y/n]?} "
read answer
case "$answer" in
y|Y|yes|YES|Yes) return 0 ;;
*) return 1;;
esac
}
subscript_failed(){
echo "---------------------------------------------------"
echo "$1 did not exit with a success return code."
echo "Something may went wrong"
yesno_continue \
&& echo "CONTINUING ANYWAY" \
|| die "component failed to run"
}
wait_to_continue(){
printf "Press <Enter> to continue..."
read _
}
cat <<EOF
0. Introduction"
Welcome to the Raspberry Pi setup script!
What you need? An internet connection and some time :)
---
Info:
date: $(date)
linux version: $(uname -r)
setup script version: $_VERSION
---
Warning: the setup script is a work in progress.
Bugs and missing features are expected.
EOF
wait_to_continue
echo "1. Package operations"
echo "1.1. Removing unnecessary packages"
echo "Following packages will be removed:"
for p in $PACKAGES_TO_REMOVE; do
echo " - $p"
done
if yesno_continue; then
for p in $PACKAGES_TO_REMOVE; do
sudo apt remove "$p" || subscript_failed "apt remove $p"
done
else
printf "Custom list of packages to remove (leave blank if none): "
read answer
if [ -n "$answer" ]; then
sudo apt remove $answer || subscript_failed "apt remove"
else
echo "Skipping package remove"
fi
unset answer
fi
echo "1.2. Updating package database"
sudo apt update || subscript_failed "apt update"
echo "1.3. Installing setup dependencies"
for p in $PACKAGES_REQUIRED; do
sudo apt install "$p" || subscript_failed "apt install $p"
done
echo "1.3.1. Installing shclrz"
git clone "https://github.com/alexcoder04/shclrz" && cd shclrz || subscript_failed "clone shclrz"
sudo make install || subscript_failed "install shclrz"
echo "1.4. Installing software" | shclrz -f cyan
for p in $PACKAGES_TO_INSTALL; do
sudo apt install "$p" || subscript_failed "apt install $p"
done
echo "1.4.1. Installing starship" | shclrz -f cyan
if yesno_continue "Do you want to install starship [Y/n]? " then
sudo sh -c "$(curl -fsSL https://starship.rs/install.sh)" || subscript_failed "install starship"
fi
echo "2. System configuration" | shclrz -f cyan
echo "2.1. Forcing password confirmation by sudo" | shclrz -f cyan
[ -f /etc/sudoers.d/010_pi-nopasswd ] && sudo rm -v /etc/sudoers.d/010_pi-nopasswd
echo "2.2. Configuration with raspi-config" | shclrz -f cyan
cat <<EOF
What you can do
- enable SSH
- enable picamera
- change login to CLI interface
EOF
wait_to_continue
sudo raspi-config
if yesno_continue "Configure GUI [y/n]?"; then
echo "2.3.1. Installing GUI packages..." | shclrz -f cyan
for p in $PACKAGES_GRAPHICAL; do
sudo apt install "$p" || subscript_failed "apt install $p"
done
echo "2.3.2. Configuring themes: running lxappearance..." | shclrz -f cyan
echo "lxappearance is a graphical program which will open up now"
echo "Just close it after you made the configurations and this script will go on"
wait_to_continue
lxappearance
echo "2.4. Configuring i3 as default desktop enviroment..." | shclrz -f cyan
if yesno_continue "Set i3 as your window manager [Y/n]? " then
echo "Writing i3 to ~/.xsession..."
cat >"$HOME/.xsession" <<EOF
#!/bin/sh
exec /usr/bin/i3
EOF
fi
else
echo "skipping 2.3. and 2.4. - GUI" | shclrz -f yellow
fi
echo "2.5. Configuring fstab" | shclrz -f cyan
if yesno_continue "Do you want to use a ramdisk for /tmp?"; then
echo "Creating fstab backup"
sudo cp -v /etc/fstab /etc/fstab.bak
line="tmpfs /tmp tmpfs defaults,size=25% 0 0"
echo "Default configuration for the ramdisk:"
echo "$line"
if ! yesno_continue; then
echo "Enter custom ramdisk configuration line:"
read line
fi
cat <<EOF | sudo tee -a /etc/fstab
# ramdisk configured with raspi-setup
$line
EOF
unset line
fi
echo "2.6. Configuring dotfiles system: skipping" | shclrz -f yellow
echo "2.7. Configuring default shell" | shclrz -f cyan
cat /etc/shells
printf "Type in shell path: "
read answer
chsh -s "$answer" || subscript_failed "choose shell"
unset answer
echo "3. Completion." | shclrz -f cyan
echo "Please reboot your Raspberry Pi to complete the setup!" | shclrz -F bold -f yellow
echo "Have fun tinkering with your Raspberry Pi!" | shclrz -F bold
echo "Report any bugs in the setup script to https://github.com/alexcoder04/raspi-setup/issues"