-
Notifications
You must be signed in to change notification settings - Fork 1
/
alpineboot
46 lines (39 loc) · 1.24 KB
/
alpineboot
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
# pipe this to ash
# Note that this is cached by github for a short while
function main {
add_repos
install_packages
add_user "$1" "$2"
get_dotfiles "$1"
}
function add_user {
useradd -m -p "$2" "$1"
file=/etc/doas.d/doas.conf
echo "permit nopass root as $1" >> $file
echo "permit nopass $1 as root" >> $file
ls -lah $file
chown root:root $file
}
function install_packages {
# https://pkgs.alpinelinux.org/contents?branch=v3.16&arch=x86_64
apk add kbd terminus-font openssh mosh git shadow doas rsync
}
function add_repos {
version="v3.16"
add_repo "https://ftp.acc.umu.se/mirror/alpinelinux.org/$version/main"
add_repo "https://ftp.acc.umu.se/mirror/alpinelinux.org/$version/community"
add_repo "https://mirrors.dotsrc.org/alpine/$version/main"
add_repo "https://mirrors.dotsrc.org/alpine/$version/community"
}
function add_repo {
local file=/etc/apk/repositories
grep -q -F "$1" $file || echo "$1" >> $file
}
function get_dotfiles {
if [ ! -e "/home/$1/code/dotfiles" ]; then
doas -u "$1" mkdir -p "/home/$1/code"
doas -u "$1" git clone https://github.com/flugsio/dotfiles "/home/$1/code/dotfiles" -b alpinewip
fi
doas -u "$1" ash -c "cd /home/$1/code/dotfiles; git pull; ./install_ash"
}
main flugsio "$1"