This repository was archived by the owner on Jan 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathminimal.sh
executable file
·117 lines (94 loc) · 3.25 KB
/
minimal.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
#
# Created on Aug 15, 2016
#
# @author: sgoldsmith
#
# Second stage of debootstrap for PINE64 that will create minimal Ubuntu 16.04
# (Xenial) root file system. This is an interactive script!
#
# Steven P. Goldsmith
#
# Prerequisites:
#
# o start.sh completed
#
# Get start time
dateformat="+%a %b %-eth %Y %I:%M:%S %p %Z"
starttime=$(date "$dateformat")
starttimesec=$(date +%s)
# Start off in root dir
cd "/root"
# Get current directory
curdir=$(cd `dirname $0` && pwd)
# stdout and stderr for commands logged
logfile="$curdir/minimal.log"
rm -f $logfile
# Simple logger
log(){
timestamp=$(date +"%m-%d-%Y %k:%M:%S")
echo "\n$timestamp $1"
echo "\n$timestamp $1" >> $logfile 2>&1
}
# debootstrap second stage
log "Debootstrap second stage"
/debootstrap/debootstrap --second-stage
# Add repos
log "Configuring repositories"
cat << EOF > /etc/apt/sources.list
deb http://ports.ubuntu.com/ubuntu-ports/ xenial main universe restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main universe restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main universe restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main universe restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ xenial multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates multiverse
EOF
apt-get update >> $logfile 2>&1
# Pick your native language pack instead of en if desired
log "Configure language"
apt-get -y install language-pack-en-base
log "Configure timezone"
dpkg-reconfigure tzdata
log "Installing base packages"
apt-get -y install sudo software-properties-common isc-dhcp-client udev netbase ifupdown iproute openssh-server iputils-ping wget net-tools wireless-tools wpasupplicant ntpdate ntp less tzdata console-common nano
# Setup ethernet as DHCP, create the loopback interface, leave wireless commented out
log "Configuring networking"
cat << EOF > /etc/network/interfaces.d/lo
auto lo
iface lo inet loopback
EOF
cat << EOF > /etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet dhcp
EOF
# Set hostname
echo "pine64" > /etc/hostname
# Setting a root password
log "Change root password"
passwd root
# Adding new user
log "Add test user with sudo access"
adduser test
adduser test sudo
# Get end time
endtime=$(date "$dateformat")
endtimesec=$(date +%s)
# Show elapse time
elapsedtimesec=$(expr $endtimesec - $starttimesec)
ds=$((elapsedtimesec % 60))
dm=$(((elapsedtimesec / 60) % 60))
dh=$((elapsedtimesec / 3600))
displaytime=$(printf "%02d:%02d:%02d" $dh $dm $ds)
log "Elapsed time: $displaytime\n"
exit 0