Skip to content
This repository was archived by the owner on Aug 14, 2023. It is now read-only.

Commit b0317eb

Browse files
Merge pull request #34 from bspeice/init_resize
Initial draft for init_resize
2 parents 7b8d785 + e06a427 commit b0317eb

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

builder/files/.first_boot

Whitespace-only changes.

builder/files/aafirstboot

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: aafirstboot
4+
# Required-Start: $remote_fs $all
5+
# Required-Stop:
6+
# Default-Start: 2 3 4 5 S
7+
# Default-Stop:
8+
# Short-Description: First boot system setup
9+
### END INIT INFO
10+
11+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
12+
13+
. /lib/init/vars.sh
14+
. /lib/lsb/init-functions
15+
16+
dev_p2="/dev/mmcblk0p2"
17+
dev=${dev_p2%??}
18+
19+
case "$1" in
20+
start)
21+
# ok, its the very first boot, we need to resize the disk.
22+
p2_start=`fdisk -l $dev | grep p2 | awk '{print $2}'`
23+
p2_finish=$((`fdisk -l $dev | grep Disk | grep sectors | awk '{printf $7}'` - 2048))
24+
25+
fdisk $dev <<EOF &>> /home/odroid/resize.log
26+
p
27+
d
28+
2
29+
n
30+
p
31+
2
32+
$p2_start
33+
$p2_finish
34+
p
35+
w
36+
EOF
37+
sync
38+
sleep 5
39+
partprobe
40+
sync
41+
sleep 5
42+
log_daemon_msg "Resizing /" &&
43+
resize2fs $dev_p2 &&
44+
rm -rf /aafirstboot
45+
[ ! -f /etc/ssh/ssh_host_rsa_key ] && dpkg-reconfigure openssh-server
46+
sync
47+
;;
48+
restart|reload|force-reload)
49+
echo "Error: argument '$1' not supported" >&2
50+
exit 3
51+
;;
52+
stop)
53+
;;
54+
*)
55+
echo "Usage: $0 start|stop" >&2
56+
exit 3
57+
;;
58+
esac

builder/files/etc/rc.local

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
4+
if [ -f /aafirstboot ]; then /aafirstboot start ; fi
5+
6+
exit 0

0 commit comments

Comments
 (0)