-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.sh
executable file
·404 lines (310 loc) · 10.7 KB
/
config.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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#!/bin/bash
function main {
# loop args
if [[ $# -ne 0 ]] ; then
for var in "$@" ; do
eval $var
done
exit 1
fi
# menu
while true; do
read -n 1 -p "
config
===================
1) General config (systemd timeout, kde index)
2) Pacman mirror (pacoloco)
3) Swap
4) Steam
u) Update pacman
f) Fix pacman keys
apps
===================
5) Base Apps
6) Media Development Apps
7) Chinese pinyin virtual keyboard support
9) Android SDK/NDK
extras
===================
h) HDMI CEC
b) audio bluetooth
s) audio network server
c) audio network client
m) microcontroller udev rules
*) Any key to exit
:" ans;
reset
case $ans in
2) fn_pacman_mirror ;;
1) fn_general_config ;;
3) fn_swap ;;
4) fn_setup_steam ;;
5) fn_base_apps ;;
6) fn_media_development_apps ;;
h) fn_cec ;;
b) fn_audio_bluetooth ;;
s) fn_audio_network_server ;;
c) fn_audio_network_client ;;
m) fn_microcontroller ;;
7) fn_pinyin ;;
9) fn_android ;;
f) fn_fix_pacman ;;
u) fn_update_pacman ;;
*) $SHELL ;;
esac
done
}
function fn_fix_pacman {
sudo pacman -Syy
sudo pacman-key --refresh-keys
sudo pacman-key --populate manjaro
#sudo pacman-key --populate archlinux manjaro
sudo ./util.sh -i archlinux-keyring
}
function fn_update_pacman {
sudo ./util.sh -i archlinux-keyring
sudo pacman -Syyu
}
function fn_android {
./util.sh -i android-ndk android-tools clang llvm lld jdk17-openjdk
# todo:
# bash rc env paths for java, sdk, ndk
# reboot
}
function fn_pinyin {
# https://forum.manjaro.org/t/chinese-language-support/115416/5
./util.sh -i adobe-source-han-sans-cn-fonts adobe-source-han-serif-cn-fonts
./util.sh fcitx5 fcitx5-gtk fcitx5-qt fcitx5-configtool fcitx5-chinese-addons manjaro-asian-input-support-fcitx5
}
function fn_microcontroller {
# arduino
sudo tee /etc/udev/rules.d/01-ttyusb.rules > /dev/null << EOL
SUBSYSTEMS=="usb-serial", TAG+="uaccess"
EOL
# NRF
sudo tee /etc/udev/rules.d/71-nrf.rules > /dev/null << EOL
ACTION!="add", SUBSYSTEM!="usb_device", GOTO="nrf_rules_end"
# Set /dev/bus/usb/*/* as read-write for all users (0666) for Nordic Semiconductor devices
SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", MODE="0666"
# Flag USB CDC ACM devices, handled later in 99-mm-nrf-blacklist.rules
# Set USB CDC ACM devnodes as read-write for all users
KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1915", MODE="0666", ENV{NRF_CDC_ACM}="1"
LABEL="nrf_rules_end"
EOL
# NRF
sudo tee /etc/udev/rules.d/99-mm-nrf-blacklist.rules > /dev/null << EOL
# 99-modemmmanager-acm-fix.rules
# Previously flagged nRF USB CDC ACM devices shall be ignored by ModemManager
ENV{NRF_CDC_ACM}=="1", ENV{ID_MM_CANDIDATE}="0", ENV{ID_MM_DEVICE_IGNORE}="1"
EOL
# load new uev rule
udevadm control --reload
udevadm trigger
# install after permissions set
#./util.sh -i yay
#./util.sh -i arduino-ide-bin
}
function fn_audio_network_server {
./util.sh -i pipewire-zeroconf
sudo systemctl enable avahi-daemon
sudo systemctl start avahi-daemon
sudo tee /etc/pipewire/pipewire-pulse.conf.d/50-network-party.conf > /dev/null << EOL
context.exec = [
{ path = "pactl" args = "load-module module-native-protocol-tcp" }
{ path = "pactl" args = "load-module module-zeroconf-discover" }
{ path = "pactl" args = "load-module module-zeroconf-publish" }
]
EOL
}
function fn_audio_network_client {
./util.sh -i pipewire-zeroconf
sudo systemctl enable avahi-daemon
sudo systemctl start avahi-daemon
#mkdir -p $HOME/.config/pipewire/pipewire.conf.d/
# pw-cli load-module libpipewire-module-raop-discover
# PIPEWIRE_DEBUG=3 pw-cli -m load-module libpipewire-module-raop-discover
# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1542
sudo tee /etc/pipewire/pipewire.conf.d/raop-discover.conf > /dev/null << EOL
context.modules = [
{
name = libpipewire-module-raop-discover
args = { }
}
]
EOL
}
function fn_audio_bluetooth {
USER=$(id -un)
echo "Enter visible bluetooth name: "
read bluetooth_name
#echo "Enter bluetooth pin (eg 123456): "
#read bluetooth_pin
#./util.sh -i bluez bluez-utils bluez-tools
./util.sh -i python-dbus
# bluetooth config
# double qoutes to expand variable
sudo sed -i "s/.*Name =.*/Name = ${bluetooth_name}/" /etc/bluetooth/main.conf
sudo sed -i 's/#DiscoverableTimeout = 0/DiscoverableTimeout = 0/' /etc/bluetooth/main.conf
sudo sed -i 's/#AlwaysPairable = false/AlwaysPairable = true/' /etc/bluetooth/main.conf
sudo sed -i 's/#PairableTimeout = 0/PairableTimeout = 0/' /etc/bluetooth/main.conf
sudo sed -i 's/#JustWorksRepairing.*/JustWorksRepairing = always/' /etc/bluetooth/main.conf
sudo sed -i 's/#AutoEnable=true/AutoEnable=true/' /etc/bluetooth/main.conf
# might need one of the following?
# sudo hciconfig hci0 sspmode 0
# sudo hciconfig hci0 sspmode 1
#sudo hciconfig hci0 noauth
#/etc/systemd/system/
sudo tee /usr/lib/systemd/user/bt.service > /dev/null << EOL
[Unit]
Description=Bluetooth speaker agent
After=network.target bluetooth.service dbus.service
[Service]
TimeoutStartSec=60
ExecStartPre=/usr/bin/sleep 20
Environment=PYTHONUNBUFFERED=1
ExecStart=python ${HOME}/Projects/scripts/services/speaker-agent.py
#User=${USER}
#Group=${USER}
[Install]
WantedBy=default.target
EOL
sudo systemctl daemon-reload
sudo systemctl --global enable bt.service
sudo systemctl start bt.service
}
function fn_cec {
# https://wiki.archlinux.org/index.php/Users_and_groups#User_management
#ls -l /dev/ttyUSB0
#id -Gn
#stat /dev/ttyACM0 <- should show which user group has access to device
./util.sh -i libcec
USER=$(id -un)
sudo gpasswd -a $USER uucp
sudo gpasswd -a $USER lock
# might not need a reboot, test it
getent group uucp
notify-send 'CEC' 'Please reboot!'
}
function fn_setup_steam {
./util.sh -i steam
#mkdir
mkdir -p $HOME/Games/Steam
# move existing install
mv $HOME/.local/share/Steam $HOME/Games
# create compat tools dir
mkdir $HOME/Games/Steam/compatibilitytools.d
# remove unused
rm -r $HOME/.local/share/Steam
# create symlink
#rm -r $HOME/.local/share/Steam
ln -s $HOME/Games/Steam $HOME/.local/share/Steam
# steam fix
# find ~/.steam/root/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" -o -name "libgpg-error.so*" \) -print -delete
notify-send 'Steam' 'Game on!'
}
function fn_pacman_mirror {
# setup pacman mirror
echo "Local pacman mirror computer name/ip (eg: update.lan): "
read computer_name
echo "Local pacman mirror repo (manjaro or archlinux): "
read repo_name
# replace
# Include = /etc/pacman.d/mirrorlist
# with
# Server = http://${computer_name}:9129/repo/${repo_name}/\$repo/\$arch
# manjaro needs /os removed
if [ $repo_name = 'manjaro' ]; then
sudo sed -i "s,Include = /etc/pacman.d/mirrorlist,Server = http://${computer_name}:9129/repo/${repo_name}/\$repo/\$arch,g" /etc/pacman.conf
else
sudo sed -i "s,Include = /etc/pacman.d/mirrorlist,Server = http://${computer_name}:9129/repo/${repo_name}/\$repo/os/\$arch,g" /etc/pacman.conf
fi
#sudo bash -c "cat > /etc/pacman.d/mirrorlist" << EOL
#Server = http://${computer_name}:9129/repo/${repo_name}/\$repo/\$arch
#EOL
notify-send 'Config' 'Pacman cache updated'
}
function fn_general_config {
# fix systemd shutdown timeout
sudo sed -i -e "s/#DefaultTimeoutStopSec=90s/DefaultTimeoutStopSec=5s/g" /etc/systemd/system.conf
sudo sed -i -e "s/#DefaultTimeoutStartSec=90s/DefaultTimeoutStartSec=5s/g" /etc/systemd/system.conf
# fix logs to be no more than 50mb
sudo sed -i -e "s/#SystemMaxUse=/SystemMaxUse=50M/g" /etc/systemd/journald.conf
# disable broken kde search
balooctl disable
notify-send 'Config' 'General config complete'
}
function fn_swap {
# https://coreos.com/os/docs/latest/adding-swap.html
# https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
# https://wiki.archlinux.org/index.php/Swap#Manually
local_path=/swapfile
# ${string/regexp/replacement}
swap_path_name="${local_path////-}"
swap_path_name="${swap_path_name:1:${#swap_path_name}}"
echo "Mounting: $local_path as $swap_path_name"
# create 16gb swap
# 1024bytes * 1024mb * xxxgb
sudo swapoff -a
echo "How much swap in GB (eg 16 = 16GB): "
read swap_size
# btrfs specific
sudo truncate -s 0 $local_path
sudo chattr +C $local_path
sudo btrfs property set $local_path compression none
sudo fallocate -l ${swap_size}G $local_path
#sudo dd if=/dev/zero of=$local_path bs=1M count=8000
#sudo chown root:root /swapfile
sudo chmod 0600 $local_path
# make swap and turn it on
sudo mkswap $local_path
sudo swapon $local_path
sudo bash -c "cat > /etc/systemd/system/$swap_path_name.swap" << EOL
[Unit]
Description=mount swap
[Swap]
What=$local_path
[Install]
WantedBy=multi-user.target
EOL
# adjust swappiness here?
# enable swap
sudo systemctl enable $swap_path_name.swap
# show status
free -m
#swapon
notify-send 'Swap' 'Created'
}
function fn_base_apps {
# remove old stuff
# use pactree qt4 - to list packages dependancies
echo -e '\n\nRemoving packages...'
./util.sh -r yakuake
# install software
echo -e '\n\nInstalling packages...'
./util.sh -i yay base-devel openssh partitionmanager filelight kio-extras plasma-browser-integration libreoffice firefox keepassxc git rustup vulkan-radeon lib32-vulkan-radeon sshfs
# printer support
./util.sh -i cups cups-pdf system-config-printer avahi
sudo systemctl enable --now cups.service
# aur software
echo -e '\n\nInstalling AUR packages...'
./util.sh -i visual-studio-code-bin
# enable ssh
sudo systemctl enable sshd.service
sudo systemctl start sshd.service
# enable bluetooth
sudo systemctl enable bluetooth
# disable firewall - endevour
sudo systemctl stop firewalld
sudo systemctl disable --now firewalld
#sudo pacman -R firewalld
echo -e '\n\ninstall complete'
notify-send 'Applications' 'Install completed'
}
function fn_media_development_apps {
echo -e '\n\nInstalling media development apps...'
./util.sh -i blender audacity krita obs-studio inkscape handbrake
echo -e '\n\ninstall complete'
notify-send 'Applications' 'Install completed'
}
# pass all args
main "$@"