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 pathstart.sh
executable file
·81 lines (67 loc) · 1.82 KB
/
start.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
#!/bin/sh
#
# Created on Aug 15, 2016
#
# @author: sgoldsmith
#
# First stage of debootstrap for PINE64 that will create minimal Ubuntu 16.04
# (Xenial) root file system. Once the script completes you are in chroot and
# /root/minimal.sh is executed.
#
# Steven P. Goldsmith
#
# Prerequisites:
#
# o Install latest Ubuntu 16.04 for PINE64 from https://www.stdin.xyz/downloads/people/longsleep/pine64-images/ubuntu
# o Login to PINE64 and do the following:
# o sudo apt-get update
# o sudo apt-get upgrade
# o sudo ./start.sh
#
# Get start time
dateformat="+%a %b %-eth %Y %I:%M:%S %p %Z"
starttime=$(date "$dateformat")
starttimesec=$(date +%s)
# Get current directory
curdir=$(cd `dirname $0` && pwd)
# Build dir
builddir="$curdir/xenial-arm64"
# stdout and stderr for commands logged
logfile="$curdir/start.log"
rm -f $logfile
# Get architecture
arch=$(uname -m)
# Ubuntu version
ubuntuver=$DISTRIB_RELEASE
# Simple logger
log(){
timestamp=$(date +"%m-%d-%Y %k:%M:%S")
echo "\n$timestamp $1"
echo "\n$timestamp $1" >> $logfile 2>&1
}
# Install dependenices
log "Installing dependenices..."
apt-get -y install debootstrap >> $logfile 2>&1
# Remove build dir and create
log "Removing builddir $builddir"
rm -rf "$builddir"
mkdir -p "$builddir"
log "Debootstrap first stage to $builddir"
debootstrap --foreign --arch arm64 xenial "$builddir" >> $logfile 2>&1
# Copy next stage minimal.sh
cp "minimal.sh" "$builddir/root/."
# Go to chroot
log "chroot $builddir"
chroot "$builddir" "./root/minimal.sh"
# 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"
exit 0