This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
chroot-script.sh
72 lines (52 loc) · 1.93 KB
/
chroot-script.sh
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
#! /usr/bash
set -ex
### configure Debian Jessie base ###
# use standard Debian apt repositories
tee /etc/apt/sources.list << EOF
deb http://httpredir.debian.org/debian jessie main
deb-src http://httpredir.debian.org/debian jessie main
deb http://httpredir.debian.org/debian jessie-updates main
deb-src http://httpredir.debian.org/debian jessie-updates main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main
EOF
# upgrade to latest Debian package versions
apt-get update
apt-get upgrade -y
### configure network and systemd services ###
# set ethernet interface eth0 to dhcp
tee /etc/systemd/network/eth0.network << EOF
[Match]
Name=eth0
[Network]
DHCP=yes
EOF
# enable networkd
systemctl enable systemd-networkd
# configure and enable resolved
ln -sfv /run/systemd/resolve/resolv.conf /etc/resolv.conf
DEST=$(readlink -m /etc/resolv.conf)
mkdir -p $(dirname $DEST)
touch /etc/resolv.conf
systemctl enable systemd-resolved
# enable ntp with timesyncd
sed -i 's|#Servers=|Servers=|g' /etc/systemd/timesyncd.conf
systemctl enable systemd-timesyncd
# set default locales to 'en_US.UTF-8'
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
locale-gen
echo 'locales locales/default_environment_locale select en_US.UTF-8' | debconf-set-selections
dpkg-reconfigure -f noninteractive locales
### HypriotOS default settings ###
# set hostname
echo "$HYPRIOT_HOSTNAME" > /etc/hostname
# install Hypriot group and user
addgroup --system --quiet $HYPRIOT_GROUPNAME
useradd -m $HYPRIOT_USERNAME --group $HYPRIOT_GROUPNAME --shell /bin/bash
echo "$HYPRIOT_USERNAME:$HYPRIOT_PASSWORD" | /usr/sbin/chpasswd
# add user to sudoers group
echo "$HYPRIOT_USERNAME ALL=NOPASSWD: ALL" > /etc/sudoers.d/user-$HYPRIOT_USERNAME
chmod 0440 /etc/sudoers.d/user-$HYPRIOT_USERNAME
# set HypriotOS version infos
echo "HYPRIOT_OS=\"HypriotOS/${BUILD_ARCH}\"" >> /etc/os-release
echo "HYPRIOT_TAG=\"${HYPRIOT_TAG}\"" >> /etc/os-release