Skip to content
Permalink
Browse files

Add nems-install command

  • Loading branch information...
NEMS Linux
NEMS Linux committed Jul 1, 2019
1 parent afbddbb commit 231652e87bc50736174541733d3ad2d782dab6fa
Showing with 193 additions and 0 deletions.
  1. +6 −0 fixes.sh
  2. +170 −0 installers/install-vim3.sh
  3. +17 −0 installers/install.sh
@@ -298,6 +298,12 @@ fi

if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then

# Add nems-install command
if [[ ! -e /usr/local/bin/nems-install ]]; then
ln -s /usr/local/share/nems/nems-scripts/installers/install-vim3.sh /usr/local/bin/nems-install
fi


# Increase upload size for background images
if [[ -e /etc/php/7.3/phpdbg/php.ini ]]; then
reloadapache=0
@@ -0,0 +1,170 @@
#!/bin/bash

# Requires DDBR installed at /usr/bin/ddbr

if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root" 2>&1
exit 1
fi

platform=$(/usr/local/bin/nems-info platform)
if (( $platform == 120 )) || (( $platform == 121 )); then

echo ""
echo "Khadas VIM3 Detected. Installing NEMS Linux to integrated eMMC."
echo ""
echo "This will destroy everything you already have on your VIM3 eMMC."

read -r -p "Are you sure? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "Alright, carrying on."
else
echo "Alright, aborting."
exit
fi

# The block device corresponding with the VIM3 eMMC drive
DEV_EMMC=/dev/mmcblk0

echo "Start backup u-boot default"

dd if="${DEV_EMMC}" of=/boot/u-boot-default.img bs=1M count=4

echo "Start create MBR and partittion"

parted -s "${DEV_EMMC}" mklabel msdos
parted -s "${DEV_EMMC}" mkpart primary fat32 700M 828M
parted -s "${DEV_EMMC}" mkpart primary ext4 829M 100%

echo "Start restore u-boot"

dd if=/boot/u-boot-default.img of="${DEV_EMMC}" conv=fsync bs=1 count=442
dd if=/boot/u-boot-default.img of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1

sync

echo "Done"

echo "Start copy system for eMMC."

mkdir -p /ddbr
chmod 777 /ddbr

PART_BOOT="${DEV_EMMC}p1"
PART_ROOT="${DEV_EMMC}p2"
DIR_INSTALL="/ddbr/install"

if [ -d $DIR_INSTALL ] ; then
rm -rf $DIR_INSTALL
fi
mkdir -p $DIR_INSTALL

if grep -q $PART_BOOT /proc/mounts ; then
echo "Unmounting BOOT partiton."
umount -f $PART_BOOT
fi
echo -n "Formatting BOOT partition..."
mkfs.vfat -n "BOOT_EMMC" $PART_BOOT
echo "done."

mount -o rw $PART_BOOT $DIR_INSTALL

echo -n "Copying BOOT..."
cp -r /boot/* $DIR_INSTALL && sync
echo "done."

echo -n "Edit init config..."
sed -e "s/ROOTFS/ROOT_EMMC/g" \
-i "$DIR_INSTALL/uEnv.ini"
echo "done."

rm $DIR_INSTALL/s9*
rm $DIR_INSTALL/aml*

umount $DIR_INSTALL

if grep -q $PART_ROOT /proc/mounts ; then
echo "Unmounting ROOT partiton."
umount -f $PART_ROOT
fi

echo "Formatting ROOT partition..."
mke2fs -F -q -t ext4 -L ROOT_EMMC -m 0 $PART_ROOT
e2fsck -n $PART_ROOT
echo "done."

echo "Copying ROOTFS."

mount -o rw $PART_ROOT $DIR_INSTALL

cd /
echo "Copy BIN"
tar -cf - bin | (cd $DIR_INSTALL; tar -xpf -)
#echo "Copy BOOT"
#mkdir -p $DIR_INSTALL/boot
#tar -cf - boot | (cd $DIR_INSTALL; tar -xpf -)
echo "Create DEV"
mkdir -p $DIR_INSTALL/dev
#tar -cf - dev | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy ETC"
tar -cf - etc | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy HOME"
tar -cf - home | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy LIB"
tar -cf - lib | (cd $DIR_INSTALL; tar -xpf -)
echo "Create MEDIA"
mkdir -p $DIR_INSTALL/media
#tar -cf - media | (cd $DIR_INSTALL; tar -xpf -)
echo "Create MNT"
mkdir -p $DIR_INSTALL/mnt
#tar -cf - mnt | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy OPT"
tar -cf - opt | (cd $DIR_INSTALL; tar -xpf -)
echo "Create PROC"
mkdir -p $DIR_INSTALL/proc
echo "Copy ROOT"
tar -cf - root | (cd $DIR_INSTALL; tar -xpf -)
echo "Create RUN"
mkdir -p $DIR_INSTALL/run
echo "Copy SBIN"
tar -cf - sbin | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy SELINUX"
tar -cf - selinux | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy SRV"
tar -cf - srv | (cd $DIR_INSTALL; tar -xpf -)
echo "Create SYS"
mkdir -p $DIR_INSTALL/sys
echo "Create TMP"
mkdir -p $DIR_INSTALL/tmp
echo "Copy USR"
tar -cf - usr | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy VAR"
tar -cf - var | (cd $DIR_INSTALL; tar -xpf -)
sync

echo "Create fstab"

echo "/dev/root / ext4 defaults,noatime,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0
LABEL=BOOT_EMMC /boot vfat defaults 0 2" > $DIR_INSTALL/etc/fstab

rm $DIR_INSTALL/usr/bin/ddbr
rm $DIR_INSTALL/usr/bin/ddbr_backup_nand
rm $DIR_INSTALL/usr/bin/ddbr_backup_nand_full
rm $DIR_INSTALL/usr/bin/ddbr_restore_nand

cd /
sync

umount $DIR_INSTALL

echo "****************************************"
echo "* NEMS Linux installed to eMMC *"
echo "****************************************"

else
echo "This installer is for VIM3 only. Aborting."
fi

echo ""
@@ -0,0 +1,17 @@
#!/bin/bash

if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root" 2>&1
exit 1
fi

platform=$(/usr/local/bin/nems-info platform)

# Khadas VIM3 - install to eMMC
if (( $platform == 120 )) || (( $platform == 121 )); then
/usr/local/share/nems/nems-scripts/installers/install-vim3.sh
exit
fi

echo "There are no installers available for this platform."
echo ""

0 comments on commit 231652e

Please sign in to comment.
You can’t perform that action at this time.