tinstall-alpine-at-onlinenet.txt - monochromatic - monochromatic blog: http://blog.z3bra.org
HTML git clone git://z3bra.org/monochromatic
DIR Log
DIR Files
DIR Refs
---
tinstall-alpine-at-onlinenet.txt (2795B)
---
1 # Install Alpine at online.net
2
3 18 August, 2015
4
5 To install alpine linux on a dedibox SC, start in rescue mode, connect to the
6 box and run the following script as root:
7
8 #!/bin/sh
9
10 set -ex
11
12 PATH=/bin:/sbin:/usr/bin:/usr/sbin
13 KEYMAP="us us"
14 PASSWORD="changemestoopid"
15 HOST=alpine
16 ROOT_FS=ext4
17 FEATURES="ata base ide scsi usb virtio $ROOT_FS"
18 MODULES="sd-mod,usb-storage,$ROOT_FS"
19
20 REL=3.5
21 MIRROR=http://nl.alpinelinux.org/alpine
22 REPO=$MIRROR/v$REL/main
23 APKV=2.6.8-r2
24 DEV=/dev/sda
25 ROOT_DEV=${DEV}1
26 ROOT=/mnt
27 ARCH=$(uname -m)
28
29 sgdisk -Z $DEV
30 sgdisk -n 1:0:0 $DEV
31 sgdisk -t 1:8300 $DEV
32 sgdisk -c 1:root $DEV
33 sgdisk -A 1:set:2 $DEV
34
35 mkfs.$ROOT_FS -q -L root $ROOT_DEV
36 mount $ROOT_DEV $ROOT
37
38 curl -s $MIRROR/v$REL/main/$ARCH/apk-tools-static-${APKV}.apk | tar xz
39 ./sbin/apk.static --repository $REPO --update-cache --allow-untrusted --root $ROOT --initdb add alpine-base syslinux dhcpcd
40
41 cat << EOF > $ROOT/etc/fstab
42 $ROOT_DEV / $ROOT_FS defaults,noatime 0 0
43 EOF
44 echo $REPO > $ROOT/etc/apk/repositories
45
46 cat /etc/resolv.conf > $ROOT/etc/resolv.conf
47 cat << EOF > $ROOT/etc/update-extlinux.conf
48 overwrite=1
49 vesa_menu=0
50 default_kernel_opts="quiet"
51 modules=$MODULES
52 root=$ROOT_DEV
53 verbose=0
54 hidden=1
55 timeout=1
56 default=grsec
57 serial_port=
58 serial_baud=115200
59 xen_opts=dom0_mem=256M
60 password=''
61 EOF
62
63 cat << EOF > $ROOT/etc/network/interfaces
64 auto lo
65 iface lo inet loopback
66
67 auto eth0
68 iface eth0 inet dhcp
69 hostname $HOST
70 EOF
71
72 mount --bind /proc $ROOT/proc
73 mount --bind /dev $ROOT/dev
74 mount --bind /sys $ROOT/sys
75
76 chroot $ROOT /bin/sh -x << CHROOT
77 apk update
78 apk add openssh
79
80 setup-hostname -n $HOST
81
82 rc-update -q add acpid default
83 rc-update -q add crond default
84 rc-update -q add devfs sysinit
85 rc-update -q add dhcpcd boot
86 rc-update -q add dmesg sysinit
87 rc-update -q add hwdrivers sysinit
88 rc-update -q add mdev sysinit
89 rc-update -q add modules boot
90 rc-update -q add networking boot
91 rc-update -q add urandom boot
92 rc-update -q add sshd default
93 rc-update -q add ntpd default
94
95 echo features=\""$FEATURES"\" > /etc/mkinitfs/mkinitfs.conf
96
97 apk add linux-grsec
98 extlinux -i /boot
99 dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=$DEV
100 CHROOT
101
102 printf 'root:%s\n' "${PASSWORD}" | chroot $ROOT /usr/sbin/chpasswd
103
104 umount $ROOT/proc
105 umount $ROOT/dev
106 umount $ROOT/sys
107 umount $ROOT
108
109 Then restart the box into normal mode.
110
111 Thanks a lot to [uggedal](http://uggedal.com) and [sin](http://u.2f30.org/sin)
112 for their help with this.