monochromatic

monochromatic blog: http://blog.z3bra.org
git clone git://z3bra.org/monochromatic
Log | Files | Refs

install-alpine-at-onlinenet.txt (2856B)


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