host info updates
[distro-setup] / bitfolk-chroot-install
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
25 shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
26 set -eE -o pipefail
27 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
28
29
30 host=$1
31
32 case $host in
33 je)
34 ip6=2001:ba8:1f1:f09d
35 ip4=85.119.82.128
36 ;;
37 bk)
38 ip6=2001:ba8:1f1:f0c9
39 ip4=85.119.83.50
40 ;;
41 esac
42
43 debconf-set-selections <<'EOF'
44 locales locales/default_environment_locale select en_US.UTF-8
45 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
46 EOF
47
48 # /a/bin/fai/fai/config/hooks/updatebase.UBUNTU
49 debconf --owner=locales sh -c '
50 . /usr/share/debconf/confmodule
51 db_version 2.0
52 db_get locales/locales_to_be_generated &&
53 mkdir -p /var/lib/locales/supported.d &&
54 echo "$RET" > /var/lib/locales/supported.d/local'
55 dpkg-reconfigure -fnoninteractive locales
56
57 apt -y remove --purge --auto-remove netplan.io libnetplan0
58 apt update
59 apt -y install linux-virtual-hwe-20.04 grub-pc-bin openssh-server ifupdown rsync
60 mkdir -p /root/.ssh
61 chmod 700 /root/.ssh
62 cat >/root/.ssh/authorized_keys <<'EOF'
63 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDX42yru/h6r6UDRy/VwVZjcYEmNLG5/SUjv7xwu43OaW0wL+uHYg2rkfn4Ygh5o1I5pgBh2SWg8TeWuVGhgL1SCuBzzeai/+58Sny065Qak+D2WjVOuRonRelh+CBA5EpNZPuiWQkoWdf9NACTBCbS2Zu7r8OOgRqu/ruaDNePlG5+U0Wlpy3oBnpbzQiuSA3AKMW30fsCJtOBjz5qQaiPbYEKJy3AOvtbq10wliKx9TpsTzrq8dKWs7PLhZnzqVCsaq6D95IzjqXcSpx4Cga5bn+YEuAnJQ53PGA5eO+hpz6HDmawTbJlaV/Dufb9bJ/ZZy1DXzs07yWRtTEY54/X ian@iankelling.org
64 EOF
65
66 # https://tools.bitfolk.com/wiki/IPv6
67 cat >/etc/network/interfaces <<EOF
68 auto lo
69 iface lo inet loopback
70
71 # The primary network interface
72 auto eth0
73 iface eth0 inet static
74 address $ip4/21
75 gateway 85.119.80.1
76
77 iface eth0 inet6 static
78 address $ip6::2
79 netmask 64
80 gateway $ip6::1
81 post-up echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
82 post-up echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
83 post-up echo 0 > /proc/sys/net/ipv6/conf/\$IFACE/accept_ra
84 post-up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
85 post-up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf
86 post-up echo 0 > /proc/sys/net/ipv6/conf/\$IFACE/autoconf
87 EOF
88
89 cat >/etc/fstab <<'EOF'
90 /dev/xvda1 / ext4 noatime,nodiratime 0 1
91 /dev/xvdb1 none swap nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,sw 0 0
92 EOF
93
94 cat >> /etc/default/grub <<'EOF'
95 GRUB_CMDLINE_LINUX_DEFAULT=""
96 GRUB_CMDLINE_LINUX="console=hvc0"
97 EOF
98
99 update-grub
100
101 cat >/etc/systemd/resolved.conf.d/servers.conf <<'EOF'
102 [Resolve]
103 DNS=85.119.80.232 85.119.80.233
104 Domains=~.
105 EOF
106
107 cat >/etc/hostname <<EOF
108 $host
109 EOF
110
111 # from fai/fai/config/scripts/FAIBASE/10-misc
112
113 TIMEZONE=US/Eastern
114 echo $TIMEZONE >/etc/timezone
115 if [[ -L /etc/localtime ]]; then
116 ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
117 else
118 cp -f /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
119 fi
120
121
122 echo $0 SUCCESS