-
Notifications
You must be signed in to change notification settings - Fork 4
/
user-data
147 lines (142 loc) · 5.24 KB
/
user-data
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
#cloud-config
autoinstall:
version: 1
identity:
realname: ''
hostname: akash-node1
password: $6$83rvP4/b9MtfTsWi$BnyxdXLDS0n0y85g0UFwqKc9sAzhNbkWDhtx/RvRBcku5cLOaDBuRO5Q95oCWCCiH2.5O.CjqhWPqwqy0MYyJ0
username: akash
storage:
layout:
name: direct
interactive-sections:
- locale
- keyboard
ssh:
allow-pw: true
install-server: true
package_update: true
package_upgrade: true
packages:
- ubuntu-drivers-common
- cloud-guest-utils
- open-vm-tools
- net-tools
- unzip
- snapd
- bmon
- htop
- iotop
- jq
- bc
- git
- curl
- screen
- qrencode
- lvm2
- python3-pip
- gunicorn
- qemu-guest-agent
late-commands:
- |
# Runs after the user logs in anytime
cat <<EOF | tee /target/etc/profile.d/akash.sh
#!/bin/bash
clear
echo "Downloading the latest AkashOS..."
if [ -f /home/akash/start-akash.sh ]; then
rm start-akash.sh
fi
if ps aux | grep '[g]unicorn' > /dev/null
then
echo "Dashboard Running"
else
echo "Dashboard Stopped, Starting now..."
rm -rf /home/akash/dashboard
git clone https://github.com/cryptoandcoffee/akashos-dashboard/ /home/akash/dashboard
cd /home/akash/dashboard ; git pull
sudo systemctl start gunicorn.service
cd /home/akash
echo "Dashboard Started"
fi
wget -q --no-cache https://raw.githubusercontent.com/cryptoandcoffee/akashos/main/start-akash.sh
chmod +x ./start-akash.sh ; ./start-akash.sh
EOF
- |
cat <<EOF | tee /target/etc/issue
---------------------------------------------------------------------------------------|
|
| Welcome to Akash OS Ubuntu 24.04 LTS \l
| Default User : akash
| Default Password : akash
| Default Hostname : \n
| IP Address : \4
| ISO Version : v0.8 Alpha
| News: : GPU is now supported with k3s.
|
|--------------------------------------------------------------------------------------|
| Web Dashboard : Open http://\4:8080 to finish the configuration.
| |
| Terminal : We recommend you login to akash@\4
| : with a terminal that supports copy and paste.
|--------------------------------------------------------------------------------------|
EOF
- |
cat <<EOF | tee /target/etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn instance to serve AkashOS Dashboard
After=network.target
[Service]
User=akash
Group=akash
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
WorkingDirectory=/home/akash/dashboard
ExecStart=gunicorn --bind 0.0.0.0:8080 --workers 1 --timeout 0 --worker-class gevent app:app
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
#Temporarily disable tty and ssh so user doesn't interrupt user-data first boot install by accident
- curtin in-target -- systemctl disable [email protected] && systemctl disable ssh
- chmod +x /target/etc/profile.d/akash.sh
- sed -i 's/ENABLED=1/ENABLED=0/' /target/etc/default/motd-news
- sed -i 's/#PrintLastLog yes/PrintLastLog no/' /target/etc/ssh/sshd_config
# Cleanup Swap
- sed -i '/\/swap\.img/d' /target/etc/fstab
- curtin in-target -- swapoff -a
- curtin in-target -- rm /swap.img
# Fast boot
- >-
curtin in-target --
sed -i /etc/default/grub -e
's/GRUB_CMDLINE_LINUX_DEFAULT=".*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/'
- curtin in-target -- update-grub
- curtin in-target -- apt-get autoremove --purge -y && apt-get autoclean -y && apt-get clean -y
- echo "The default username is 'akash' and the default password is 'akash'"
- echo "AkashOS is ready! Remove the CD and reboot."
#Runs only once during the initial boot after installation of the ISO
user-data:
disable_root: false
runcmd:
- |
chown akash:akash /etc/systemd/system/gunicorn.service
chmod 664 /etc/systemd/system/gunicorn.service
chown akash:akash /etc/profile.d/akash.sh
chmod 664 /etc/profile.d/akash.sh
chmod +x /etc/profile.d/akash.sh
echo "akash ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers >/dev/null 2>&1
sudo -u akash touch /home/akash/.hushlogin
sudo -u akash git clone https://github.com/cryptoandcoffee/akashos-dashboard/ /home/akash/dashboard >/dev/null 2>&1
sudo -u akash pip install --user -r /home/akash/dashboard/requirements.txt >/dev/null 2>&1
mkdir -p /home/akash/.ssh
KEY_LOCATION="/home/akash/.ssh/id_rsa"
PASSPHRASE=""
HOSTNAME="akash-node-1"
ssh-keygen -t rsa -C "$HOSTNAME" -f "$KEY_LOCATION" -P "$PASSPHRASE" >/dev/null 2>&1
chown -R akash:akash /home/akash/
#System ready - show login and enable sshd and dashboard
systemctl enable --now ssh >/dev/null 2>&1
systemctl enable --now gunicorn >/dev/null 2>&1
systemctl enable --now [email protected] >/dev/null 2>&1
touch /etc/cloud/cloud-init.disabled