This repository has been archived by the owner on May 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
yunocube.sh
executable file
·52 lines (39 loc) · 1.65 KB
/
yunocube.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
#!/bin/bash
set -e
set -x
TARGET_DIR=./tmp
REP=$(dirname $0)
APT='DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes'
IMAGE=$(echo $1 | sed 's/yunohost/internetcube/')
cp $1 $IMAGE
mkdir -p $TARGET_DIR
umount $TARGET_DIR || true
mount -o loop,offset=4194304 $IMAGE $TARGET_DIR
echo '. /etc/bash_completion' >> $TARGET_DIR/root/.bashrc
# Use dhcp on boot
cat <<EOT > $TARGET_DIR/etc/network/interfaces
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto usb0
allow-hotplug usb0
iface usb0 inet dhcp
EOT
# Debootstrap optimisations from igorpecovnik
# change default I/O scheduler, noop for flash media, deadline for SSD, cfq for mechanical drive
cat <<EOT >> $TARGET_DIR/etc/sysfs.conf
block/mmcblk0/queue/scheduler = noop
#block/sda/queue/scheduler = cfq
EOT
# Add firstrun and secondrun init script
install -m 755 -o root -g root ${REP}/script/resize2fs-reboot $TARGET_DIR/usr/local/bin/
install -m 755 -o root -g root ${REP}/script/hypercube/hypercube.sh $TARGET_DIR/usr/local/bin/
install -m 444 -o root -g root ${REP}/script/resize2fs-reboot.service $TARGET_DIR/etc/systemd/system/
install -m 444 -o root -g root ${REP}/script/hypercube/hypercube.service $TARGET_DIR/etc/systemd/system/
ln -f -s '/etc/systemd/system/resize2fs-reboot.service' $TARGET_DIR/etc/systemd/system/multi-user.target.wants/resize2fs-reboot.service
ln -f -s '/etc/systemd/system/hypercube.service' $TARGET_DIR/etc/systemd/system/multi-user.target.wants/hypercube.service
# Add hypercube scripts
mkdir -p $TARGET_DIR/var/log/hypercube
install -m 444 -o root -g root ${REP}/script/hypercube/install.html $TARGET_DIR/var/log/hypercube/
umount $TARGET_DIR || true
exit 0