-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloud-init.yml
323 lines (272 loc) · 11.1 KB
/
cloud-init.yml
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
#cloud-config
ssh_pwauth: false
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
- xubuntu-core
- software-properties-common
- x2goserver
- x2goserver-xsession
- x2goserver-desktopsharing
- firefox
- flatpak
- git
- lazygit
- docker.io
- python
- python3.8
- python3-pip
- meld
- curl
- gconf2
- apt-transport-https
- xserver-xorg-video-dummy
- libgtkglext1
- fzf
snap:
commands:
- ['install', '--classic', '--channel=2021.1/stable', 'intellij-idea-ultimate']
- ['install', '--classic', '--channel=2021.1/stable', 'rider']
- ['install', '--classic', '--channel=2021.1/stable', 'pycharm-professional']
- ['install', '--classic', 'code']
- ['install', 'typora']
- ['install', 'postman']
write_files:
- content: |
[Desktop Entry]
Version=1.0
Name=Mob Timer
Exec=/home/mob/mob-timer-linux-x64/mob-timer
Icon=/home/mob/mob-timer-linux-x64/resources/app/icon.ico
Terminal=false
Type=Application
Categories=Application;Development
path: /usr/share/applications/mob-timer.desktop
- content: |
#!/bin/bash
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/etc/apt/trusted.gpg.d/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
path: /opt/install-gh-cli.sh
permissions: '0755'
- content: |
alias lg="lazygit"
tdd_ts() {
curl https://gist.githubusercontent.com/gregorriegler/5c578410a619188838d3c9c6c23e09ae/raw/66f53f19c5112e78e298ffe3cc49d3c5b0655738/tdd-bootstrap-ts-mocha-chai.sh | bash -s "$1"
}
tdd_js() {
curl https://gist.githubusercontent.com/gregorriegler/3e6f5d38f74fec9f2be0c66ddf16195d/raw/d36216c683a47f72db5d4e7c8333a68066b3af60/tdd-bootstrap-js-mocha-chai.sh | bash -s "$1"
}
path: /opt/.bash_aliases
permissions: '0755'
- content: |
#!/bin/bash
launcher_plugins=()
next_plugin_id () {
local highest_number=$(xfconf-query -c xfce4-panel -p /plugins -l | cut -d"-" -f2 | cut -d"/" -f1 | sort -V -r | head -n 1)
plugin_id=$((highest_number + 1))
}
create_launcher_plugin () {
next_plugin_id
mkdir ~/.config/xfce4/panel/launcher-$plugin_id
cp $1 ~/.config/xfce4/panel/launcher-$plugin_id
xfconf-query -c xfce4-panel -p /plugins/plugin-$plugin_id -t string -s "launcher" --create
xfconf-query -c xfce4-panel -p /plugins/plugin-$plugin_id/items -t string -s "$(basename "${1%.*}").desktop" -a --create
launcher_plugins+=("$plugin_id")
}
create_launcher_plugin "/usr/share/applications/firefox.desktop"
create_launcher_plugin "/usr/share/applications/google-chrome.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/intellij-idea-ultimate_intellij-idea-ultimate.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/pycharm-professional_pycharm-professional.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/rider_rider.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/code_code.desktop"
create_launcher_plugin "/usr/share/applications/vim.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/typora_typora.desktop"
create_launcher_plugin "/usr/share/applications/org.gnome.meld.desktop"
create_launcher_plugin "/var/lib/snapd/desktop/applications/postman_postman.desktop"
create_launcher_plugin "/usr/share/applications/mob-timer.desktop"
plugins_string=""
for plugin in "${launcher_plugins[@]}"
do
plugins_string="${plugins_string} -t int -s ${plugin} "
done
## clear panel 2
xfconf-query -c xfce4-panel -p /panels/panel-2/plugin-ids -rR
## refill panel 2
xfconf-query -c xfce4-panel -p /panels/panel-2/plugin-ids \
-t int -s 15 \
-t int -s 16 \
-t int -s 17 \
-t int -s 18 \
$plugins_string \
--create
## restart panel
xfce4-panel -r
## Clear Shortcuts needed by IntelliJ
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Alt>Insert' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Alt>Delete' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/commands/custom/<Primary><Alt>l' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Alt>F7' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Primary><Shift><Alt>Left' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Primary><Shift><Alt>Right' -r -R
xfconf-query -c xfce4-keyboard-shortcuts -p '/xfwm4/custom/<Primary><Shift><Alt>Up' -r -R
setxkbmap -option caps:escape
## start X2Go Desktop Sharing
/usr/bin/x2godesktopsharing
path: /opt/init-xfce4-panel.sh
permissions: '0755'
- content: |
#!/bin/bash
set_dm() {
DISPLAY_MANAGER="lightdm"
DISPLAY_MANAGER_SERVICE="/etc/systemd/system/display-manager.service"
DEFAULT_DISPLAY_MANAGER_FILE="/etc/X11/default-display-manager"
if [ -n "${1}" ]
then
DISPLAY_MANAGER="$1"
fi
DISPLAY_MANAGER_BIN="/usr/sbin/${DISPLAY_MANAGER}"
if [ ! -e "${DISPLAY_MANAGER_BIN}" ]
then
echo "${DISPLAY_MANAGER} seems not to be a valid display manager or is not installed."
exit 1
fi
echo "${DISPLAY_MANAGER_BIN}" > "${DEFAULT_DISPLAY_MANAGER_FILE}"
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure "${DISPLAY_MANAGER}"
echo set shared/default-x-display-manager "${DISPLAY_MANAGER}" | debconf-communicate &> /dev/null
echo -n "systemd service is set to: "
readlink "${DISPLAY_MANAGER_SERVICE}"
echo -n "${DEFAULT_DISPLAY_MANAGER_FILE} is set to: "
cat "${DEFAULT_DISPLAY_MANAGER_FILE}"
echo -n "debconf is set to: "
echo get shared/default-x-display-manager | debconf-communicate
}
set_dm $1
touch /var/run/reboot-required
path: /opt/setdm.sh
permissions: '0755'
- content: |
Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
Identifier "Card0"
Option "NoDDC" "true"
Option "IgnoreEDID" "true"
Driver "dummy"
VideoRam 256000
EndSection
Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
path: /etc/X11/xorg.conf
permissions: '644'
- content: |
let anydeskId = require('fs').readFileSync("/opt/anydesk_id").toString();
require('http').createServer(function (req, res) { res.end('AnydeskId: '+ anydeskId); }).listen(3000);
path: /opt/up.js
permissions: '0755'
- content: |
#!/bin/bash
runuser -l mob -c 'bash -ic "node /opt/up.js &"'
path: /opt/up.sh
permissions: '0755'
- content: |
[Unit]
After=network.service
[Service]
ExecStart=/opt/up.sh
[Install]
WantedBy=default.target
path: /etc/systemd/system/up.service
- content: |
[SeatDefaults]
autologin-user=mob
autologin-user-timeout=0
user-session=xfce
path: /etc/lightdm/lightdm.conf.d/lightdm.conf
- content: |
#!/bin/bash
# sdkman & java
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh" ; sdk install java 17.0.2-tem ; sdk install gradle ; sdk install maven
# nvm & node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
bash -ic "nvm install node ; npm install --global yarn"
# desktop theme
/usr/bin/xfconf-query -c xsettings -p /Net/ThemeName -s "Adwaita-dark"
# install mob-timer
wget "https://github.com/gregorriegler/mob-timer/releases/download/linux/mob-timer-linux-x64.zip" -O temp.zip ; unzip temp.zip ; rm temp.zip
# Panel Shortcuts
mkdir ~/.config/autostart
echo -e "[Desktop Entry]\nType=Application\nExec=/opt/init-xfce4-panel.sh\nName=Init xfce4 Panel\nComment=Init xfce4 Panel" | tee > ~/.config/autostart/init-xfce4-panel.desktop
# Dot files
cp /opt/.bash_aliases ~/.bash_aliases
# Git Config
git config --global user.name "mob"
git config --global user.email "[email protected]"
# Kata Bootstraps
git clone https://github.com/swkBerlin/kata-bootstraps ~/kata-bootstraps
# Bookshelf Kata
git clone -b no-spoilers https://github.com/gregorriegler/Bookshelf-Kata.git ~/bookshelf-kata
# Kata Bootstraps
git clone https://github.com/emilybache/GildedRose-Refactoring-Kata.git ~/gilded-rose-refactoring-kata
cat >> ~/.profile <<- EOM
export NVM_DIR="\$HOME/.nvm"
[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" # This loads nvm
[ -s "\$NVM_DIR/bash_completion" ] && \. "\$NVM_DIR/bash_completion" # This loads nvm bash_completion
EOM
path: /opt/user-scripts.sh
permissions: '0755'
runcmd:
- /opt/setdm.sh
- rm /usr/share/xsessions/ubuntu.desktop
- rm /usr/share/xsessions/xubuntu.desktop
- rm /usr/share/wayland-sessions/ubuntu-wayland.desktop
- [wget, "https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb", -O, /tmp/packages-microsoft-prod.deb]
- dpkg -i /tmp/packages-microsoft-prod.deb
- rm /tmp/packages-microsoft-prod.deb
- apt update
- apt-get install dotnet-sdk-6.0 -y
- usermod -aG docker mob
- chmod 666 /var/run/docker.sock
- apt remove -y xfce4-screensaver xfce4-power-manager light-locker
- sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
- systemctl restart sshd
- wget https://download.anydesk.com/linux/anydesk_6.2.0-1_amd64.deb
- dpkg -i anydesk_6.2.0-1_amd64.deb
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- dpkg -i google-chrome-stable_current_amd64.deb
- /opt/install-gh-cli.sh
- printf "<!DOCTYPE NXKeystroke>\n<keystrokes></keystrokes>\n" > /etc/x2go/keystrokes.cfg
- runuser -l mob -c 'bash -ic "/opt/user-scripts.sh"'
- echo ebcontcodingdojo | anydesk --set-password
- anydesk --get-id > /opt/anydesk_id
- chmod 755 /opt/anydesk_id
- systemctl daemon-reload
- systemctl enable /etc/systemd/system/up.service
power_state:
message: Final Reboot
mode: reboot
apt:
sources:
lazygit.list:
source: "ppa:lazygit-team/release"
deadsnakes.list:
source: "ppa:deadsnakes/ppa"
# TODO
# Extract all runuser to its own script
# zsh + plugins
# automatically destroy after 4 inactive hours