initial data partition creation no longer requires two boots

This commit is contained in:
Calin Crisan 2015-11-09 01:53:28 +02:00
parent 1d93edc67d
commit 2f8a10dcf9
6 changed files with 16 additions and 43 deletions

View File

@ -37,7 +37,6 @@ rm -f $TARGET/sbin/fdformat
rm -f $TARGET/sbin/ctrlaltdel rm -f $TARGET/sbin/ctrlaltdel
rm -f $TARGET/bin/findmnt rm -f $TARGET/bin/findmnt
rm -f $TARGET/usr/bin/colcrt rm -f $TARGET/usr/bin/colcrt
rm -f $TARGET/usr/sbin/partx
rm -f $TARGET/sbin/fsfreeze rm -f $TARGET/sbin/fsfreeze
rm -f $TARGET/usr/bin/colrm rm -f $TARGET/usr/bin/colrm
rm -f $TARGET/usr/sbin/addpart rm -f $TARGET/usr/sbin/addpart

View File

@ -1,11 +1,11 @@
# /etc/fstab: static file system information.
#
# <file system> <mount pt> <type> <options> <dump> <pass> # <file system> <mount pt> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat ro,defaults 0 0 /dev/mmcblk0p1 /boot vfat ro,defaults 0 0
/dev/mmcblk0p3 /data auto defaults,noatime 0 0 /dev/mmcblk0p3 /data ext4 defaults,noatime 0 0
proc /proc proc defaults 0 0 proc /proc proc defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs mode=0777 0 0 tmpfs /dev/shm tmpfs mode=0777 0 0
tmpfs /tmp tmpfs mode=1777 0 0 tmpfs /tmp tmpfs mode=1777 0 0
sysfs /sys sysfs defaults 0 0 sysfs /sys sysfs defaults 0 0
/data/output /home/ftp/sdcard rbind rbind 0 0
/data/media /home/ftp/storage rbind rbind 0 0

View File

@ -2,20 +2,13 @@
DISK_DEV="/dev/mmcblk0" DISK_DEV="/dev/mmcblk0"
DATA_DEV="${DISK_DEV}p3" DATA_DEV="${DISK_DEV}p3"
set +e
# don't execute the script if kernel cmdline has "nodatapart" keyword
if /bin/cat /proc/cmdline | /bin/grep "nodatapart"; then
exit;
fi
start() { start() {
echo "Setting up data partition" echo "Setting up data partition"
# if the partition is not present, allocate it and issue a reboot # if the data partition is not present, create and format it
if ! [ -b $DATA_DEV ]; then if ! [ -b $DATA_DEV ]; then
echo "Allocating data partition" echo "Creating data partition"
echo -e "n echo -e "n
p p
3 3
@ -24,16 +17,13 @@ start() {
w w
" | /sbin/fdisk $DISK_DEV " | /sbin/fdisk $DISK_DEV
sync sync
sleep 1 partx -a $DISK_DEV &>/dev/null
echo b > /proc/sysrq-trigger
fi
# if the filesystem is not valid (not yet formatted), format it
if /usr/sbin/debugfs -R 'lcd /' $DATA_DEV 2>&1 | grep 'Bad magic'; then
echo "Formatting data partition" echo "Formatting data partition"
mkfs.ext4 $DATA_DEV mkfs.ext4 $DATA_DEV
mount /data
echo "Mounting data partition"
mount /data
fi fi
if df /dev/mmcblk0p3 >/dev/null 2>&1; then if df /dev/mmcblk0p3 >/dev/null 2>&1; then
@ -45,6 +35,9 @@ start() {
chmod 775 /data/output chmod 775 /data/output
chmod 775 /data/media chmod 775 /data/media
# mount any partitions depending on data folders
mount -a
# make sure a localtime symlink exists # make sure a localtime symlink exists
if ! [ -e /data/etc/localtime ]; then if ! [ -e /data/etc/localtime ]; then
ln -s /usr/share/zoneinfo/UTC /data/etc/localtime ln -s /usr/share/zoneinfo/UTC /data/etc/localtime
@ -78,10 +71,6 @@ start() {
sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration
sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration
# mount binds
mount --rbind /data/output /home/ftp/sdcard
mount --rbind /data/media /home/ftp/storage
# copy common sys config files # copy common sys config files
if [ -f /etc/watch.conf ] && ! [ -f /data/etc/watch.conf ]; then if [ -f /etc/watch.conf ] && ! [ -f /data/etc/watch.conf ]; then
cp /etc/watch.conf /data/etc/watch.conf cp /etc/watch.conf /data/etc/watch.conf
@ -89,30 +78,17 @@ start() {
fi fi
} }
stop() {
echo -n
}
restart() {
stop
start
}
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop) stop)
stop true
;;
restart|reload)
restart
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop}"
exit 1 exit 1
esac esac

View File

@ -15,9 +15,7 @@ link_nego_timeout=10
eth=eth0 eth=eth0
wlan=wlan0 wlan=wlan0
if [ -f $watch_conf ]; then test -r $watch_conf && source $watch_conf
source $watch_conf
fi
if [ -f $sys_static_conf ] && ! [ -f $static_conf ]; then if [ -f $sys_static_conf ] && ! [ -f $static_conf ]; then
mkdir -p $(dirname $static_conf) mkdir -p $(dirname $static_conf)

View File

@ -6,7 +6,6 @@ conf="/etc/sshd_config"
[ -f /usr/bin/ssh-keygen ] || exit 0 [ -f /usr/bin/ssh-keygen ] || exit 0
# Create any missing keys # Create any missing keys
mkdir -p /data/etc/ssh
/usr/bin/ssh-keygen -A /usr/bin/ssh-keygen -A
umask 077 umask 077

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set +e set +e
/bin/sync
(sleep 10 && /usr/bin/killall -STOP watchdog) & (sleep 10 && /usr/bin/killall -STOP watchdog) &
/bin/busybox reboot /bin/busybox reboot