diff options
Diffstat (limited to 'package/installer')
-rwxr-xr-x | package/installer/src/installer | 98 |
1 files changed, 91 insertions, 7 deletions
diff --git a/package/installer/src/installer b/package/installer/src/installer index fd45c443c..3c24cb6a2 100755 --- a/package/installer/src/installer +++ b/package/installer/src/installer @@ -1,5 +1,11 @@ #!/bin/sh +#set -x + +rootsize=1024 +usbrootsize=512 +cfgsize=16 + create_bootcfg() { cat << FOO > /mnt/boot/boot.cfg default 0 @@ -10,22 +16,97 @@ title OpenADK args root=/dev/sda1 title USB - kernel (usb0,0)/boot/kernel + kernel (usb0,0)/boot/kernel-usb args root=/dev/sdc1 FOO } +create_fstab() { + cat << FOO > /mnt/etc/fstab +/dev/sda2 /home ext4 defaults 0 0 +/dev/sda3 none swap sw 0 0 +FOO + +} + +create_usb_fstab() { + cat << FOO > /mnt/etc/fstab +/dev/sdc2 /home ext4 defaults 0 0 +FOO + +} + +create_home() { + mkdir -p /mnt/home + mkdir -p /tmp/home/lemote + chown 1000:1000 /tmp/home/lemote + echo "lemote:x:1000:1000:Linux User,,,:/home/lemote:/bin/mksh" >> /mnt/etc/passwd + echo "lemote:.m3Jtyyc5L4W6:15426:0:99999:7:::" >> /mnt/etc/shadow + echo "setxkbmap -option terminate:ctrl_alt_bksp" >> /tmp/home/lemote/.xsession + echo fluxbox >> /tmp/home/lemote/.xsession +} + +usb_install() { + size=$(parted -s /dev/sdc unit mb print|awk '/Disk/ {print $3}'|sed -e "s#MB##") + homesize=$(($size-$usbrootsize-$cfgsize)) + mkdir /tmp/home + parted -s /dev/sdc mklabel msdos + parted -s /dev/sdc mkpart primary ext2 0 ${usbrootsize}M 2>&1 >/dev/null + parted -s /dev/sdc mkpart primary ext2 ${usbrootsize}M ${homesize}M + parted -s /dev/sdc -- mkpart primary ext2 ${homesize}M -0 + sfdisk --change-id /dev/sdc 3 88 2>&1 >/dev/null + echo "Creating filesystem on /home" + mke2fs -q -j /dev/sdc2 + mount -t ext4 /dev/sdc2 /tmp/home + echo "Copying system to disk" + dd if=/dev/sdc of=/tmp/home/lemote.tar.gz bs=16384 skip=1024 count=8000 2>/dev/null + echo "Creating filesystem on /" + mke2fs -q -j /dev/sdc1 + mount -t ext4 /dev/sdc1 /mnt + echo "Installing system to USB disk ..." + tar xzf /tmp/home/lemote.tar.gz -C /mnt + test -x /mnt/usr/bin/sudo && chmod u+s /mnt/usr/bin/sudo + test -x /mnt/usr/bin/Xorg && chmod u+s /mnt/usr/bin/Xorg + create_home + create_bootcfg + create_usb_fstab + umount /mnt + umount /tmp/home + +} + disk_install() { - mke2fs -q -j /dev/sda1 - sync + size=$(parted -s /dev/sda unit mb print|awk '/Disk/ {print $3}'|sed -e "s#MB##") + swap=1024 + homesize=$(($size-$rootsize-$cfgsize-$swap)) + swapsize=$(($homesize+$swap)) + mkdir /tmp/home + parted -s /dev/sda mklabel msdos + parted -s /dev/sda mkpart primary ext2 0 ${rootsize}M 2>&1 >/dev/null + parted -s /dev/sda mkpart primary ext2 ${rootsize}M ${homesize}M + parted -s /dev/sda mkpart primary ext2 ${homesize}M ${swapsize}M + parted -s /dev/sda -- mkpart primary ext2 ${swapsize}M -0 + sfdisk --change-id /dev/sda 3 82 2>&1 >/dev/null + sfdisk --change-id /dev/sda 4 88 2>&1 >/dev/null sleep 2 + echo "Creating filesystem on /home" + mke2fs -q -j /dev/sda2 + mkswap /dev/sda3 + mount -t ext4 /dev/sda2 /tmp/home + echo "Copying system to disk" + dd if=/dev/sdc of=/tmp/home/lemote.tar.gz bs=16384 skip=1024 count=8000 2>/dev/null + mke2fs -q -j /dev/sda1 mount -t ext4 /dev/sda1 /mnt - tar xzvf /lemote-yeelong-eglibc-archive+kernel.tar.gz -C /mnt + echo "Installing system to hard disk ..." + tar xzf /tmp/home/lemote.tar.gz -C /mnt test -x /mnt/usr/bin/sudo && chmod u+s /mnt/usr/bin/sudo test -x /mnt/usr/bin/Xorg && chmod u+s /mnt/usr/bin/Xorg + create_home create_bootcfg + create_fstab umount /mnt + umount /tmp/home } @@ -47,15 +128,18 @@ echo " |_| " echo "" # settle down, after module load sleep 2 -echo "Should I install OpenADK to disk (y/n)" +echo "Should I install OpenADK to disk (d) or usb disk (u) or do nothing (any key)" read answer -if [ "$answer" = "y" ];then +if [ "$answer" = "d" ];then disk_install fi +if [ "$answer" = "u" ];then + usb_install +fi echo "Should I reboot now (y/n)" read answer if [ "$answer" = "y" ];then - reboot + /bin/busybox reboot -f else exit fi |