From 1ac5f126bf1b3f2e18001dab8b9f2ae6255309cf Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Mon, 22 Aug 2016 16:35:00 +0100 Subject: first doc core os revision --- core/scripts/act-chroot.sh | 54 +++++++++++++ core/scripts/chroot.sh | 9 +++ core/scripts/configure.sh | 57 ++++++++++++++ core/scripts/getiso.sh | 26 +++++++ core/scripts/install.sh | 185 +++++++++++++++++++++++++++++++++++++++++++++ core/scripts/ports.sh | 38 ++++++++++ 6 files changed, 369 insertions(+) create mode 100644 core/scripts/act-chroot.sh create mode 100644 core/scripts/chroot.sh create mode 100644 core/scripts/configure.sh create mode 100644 core/scripts/getiso.sh create mode 100644 core/scripts/install.sh create mode 100644 core/scripts/ports.sh (limited to 'core/scripts') diff --git a/core/scripts/act-chroot.sh b/core/scripts/act-chroot.sh new file mode 100644 index 0000000..587e35c --- /dev/null +++ b/core/scripts/act-chroot.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +printf "1.1.2 EFI block; (/dev/sda1):" +#read BLK_EFI +BLK_EFI="/dev/sda1" + +printf "1.1.2 boot block; (/dev/sda2):" +#read BLK_BOOT +BLK_BOOT="/dev/sda2" + +printf "1.1.2 root block; (/dev/sda3):" +#read BLK_ROOT +BLK_ROOT="/dev/sda3" +# +printf "1.1.2 var block; (/dev/sda4):" +#read BLK_VAR +BLK_VAR="/dev/sda4" +# +printf "1.1.2 usr block; (/dev/sda6):" +#read BLK_USR +BLK_USR="/dev/sda6" +# +printf "1.1.2 home block; (/dev/sda7):" +#read BLK_HOME +BLK_HOME="/dev/sda7" +# +printf "1.1.2 ports block; (/dev/sda8):\n" +#read BLK_PRT +BLK_PRT="/dev/sda8" + +printf "1.1.2 swap block; (/dev/sda9):\n" +#read BLK_SWP +BLK_SWP="/dev/sda9" + +printf "1.1.3 mount point to chroot (/mnt):" +#read CHROOT +CHROOT="/mnt" + + +mount $BLK_ROOT $CHROOT + +mount $BLK_BOOT $CHROOT/boot +mount $BLK_EFI $CHROOT/boot/efi + +mount $BLK_VAR $CHROOT/var +mount $BLK_USR $CHROOT/usr +#mount $BLK_PRT $CHROOT/usr/ports +mount $BLK_HOME $CHROOT/home + +#mount -vt devpts devpts $CHROOT/dev/pts +#mount -vt tmpfs shm $CHROOT/dev/shm +mount -t proc proc $CHROOT/proc +mount -t sysfs sys $CHROOT/sys +mount --bind /dev $CHROOT/dev diff --git a/core/scripts/chroot.sh b/core/scripts/chroot.sh new file mode 100644 index 0000000..00fbd78 --- /dev/null +++ b/core/scripts/chroot.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CHROOT=/mnt + +chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash --login + diff --git a/core/scripts/configure.sh b/core/scripts/configure.sh new file mode 100644 index 0000000..f279725 --- /dev/null +++ b/core/scripts/configure.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +ADMIN_USER=c9admin +CHROOT=/mnt +#ADMIN_PASS= + +DIR=$(dirname "$PWD"); +DIR_CONF=$DIR"/conf" + +printf "CHROOT="$CHROOT"\n"; +printf "DIR="$DIR"\n"; +printf "DIR_CONF="$DIR_CONF"\n"; +printf "ADMIN_USER="$ADMIN_USER"\n" +read PAUSE + + +#configure_crux() { + + echo "1.2.1. Set hostname and hosts;" + cp $DIR_CONF/hosts $CHROOT/etc/ + vim $CHROOT/etc/hosts + + echo "1.2.2. Set timezone;" + chroot $CHROOT /bin/bash -c tzselect + + echo "1.2.3. Set locale;" + chroot $CHROOT /bin/bash -c "localedef -i en_US -f UTF-8 en_US.UTF-8" + + echo "1.2.4.2. Create Administrator $ADMIN_USER;" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "useradd -U -m -k /etc/skel -s /bin/bash $ADMIN_USER" + +# echo "$ADMIN_USER:$ADMIN_PASS" >$CHROOT/root/foo +# chroot $CHROOT 'chpasswd > $CHROOT/etc/fstab + vim $CHROOT/etc/fstab + + echo "1.2.6. Initialization Scripts;" + cp $DIR_CONF/rc.conf $CHROOT/etc/ + vim $CHROOT/etc/rc.conf + +#} + +printf "Chroot to /mnt and set root and admin password:\n" diff --git a/core/scripts/getiso.sh b/core/scripts/getiso.sh new file mode 100644 index 0000000..18f1ad1 --- /dev/null +++ b/core/scripts/getiso.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +ISO_URL="https://serverop.de/crux/crux-3.2/iso/crux-3.2.iso" +ISO_FILE="crux-3.2.iso" + +printf "1.1.1 Path/to crux-3.2.iso (/home/user/Downloads):" +read ISO_PATH + + +#prepare_iso() { + + ISO_FILE=$ISO_PATH/$ISO_FILE + + if [ -f $ISO_FILE ]; + then + echo "File $ISO_FILE exists." + else + echo "File $ISO_FILE does not exist." + cd $ISO_PATH && { curl -k -O $ISO_URL ; cd -; } + fi + +#} + +modprobe isofs +modprobe loop +mount -o loop $ISO_FILE $CHROOT/media diff --git a/core/scripts/install.sh b/core/scripts/install.sh new file mode 100644 index 0000000..495b327 --- /dev/null +++ b/core/scripts/install.sh @@ -0,0 +1,185 @@ +#!/bin/bash +# Set Global Vars + +DIR=$(dirname "$PWD"); +DIR_PRT=$(dirname "$DIR")"/c9-ports"; +DIR_CONF=$DIR"/conf" + +printf "CHROOT="$CHROOT"\n"; +printf "DIR="$DIR"\n"; +printf "DIR_CONF="$DIR_CONF"\n"; +printf "DIR_PRT="$DIR_PRT"\n"; +read PAUSE + +printf "1.1.2 EFI block; (/dev/sda1):\n" +#read BLK_EFI +BLK_EFI="/dev/sda1" + +printf "1.1.2 boot block; (/dev/sda2):\n" +#read BLK_BOOT +BLK_BOOT="/dev/sda2" + +printf "1.1.2 root block; (/dev/sda3):\n" +#read BLK_ROOT +BLK_ROOT="/dev/sda3" +# +printf "1.1.2 var block; (/dev/sda4):\n" +#read BLK_VAR +BLK_VAR="/dev/sda4" +# +printf "1.1.2 usr block; (/dev/sda6):\n" +#read BLK_USR +BLK_USR="/dev/sda6" +# +printf "1.1.2 home block; (/dev/sda7):\n" +#read BLK_HOME +BLK_HOME="/dev/sda7" +# +printf "1.1.2 ports block; (/dev/sda8):\n" +#read BLK_PRT +BLK_PRT="/dev/sda8" + +printf "1.1.2 swap block; (/dev/sda9):\n" +#read BLK_SWP +BLK_SWP="/dev/sda9" + +printf "1.1.3 mount point to chroot (/mnt):\n" +#read CHROOT +CHROOT="/mnt" + +#manual_install() { + + echo "1.1.2 Creating File System on $BLK_EFI with fat32:" + mkfs.fat -F 32 $BLK_EFI + echo "1.1.2 Creating File System on $BLK_BOOT with ext4:" + mkfs.ext4 $BLK_BOOT + echo "1.1.2 Creating File System on $BLK_ROOT with ext4:" + mkfs.ext4 $BLK_ROOT + echo "1.1.2 Creating File System on $BLK_VAR with ext4:" + mkfs.ext4 $BLK_VAR + echo "1.1.2 Creating File System on $BLK_USR with ext4:" + mkfs.ext4 $BLK_USR + echo "1.1.2 Creating File System on $BLK_HOME with ext4:" + mkfs.ext4 $BLK_HOME +# echo "1.1.2 Creating File System on $BLK_PRT with ext4:" +# mkfs.ext4 $BLK_PRT + echo "1.1.2 Creating Swap File System on $BLK_SWP:" + #mkswap $BLK_SWP + +#} + + +#prepare_target(){ + + printf "1.1.3 mount point to chroot (/mnt):\n" + mount $BLK_ROOT $CHROOT + + mkdir -p $CHROOT/boot + mkdir -p $CHROOT/var + mkdir -p $CHROOT/usr + mkdir -p $CHROOT/media + mkdir -p $CHROOT/home + + mkdir -p $CHROOT/dev + mkdir -p $CHROOT/tmp + mkdir -p $CHROOT/proc + mkdir -p $CHROOT/sys + + mount $BLK_BOOT $CHROOT/boot + mkdir -p $CHROOT/boot/efi + mount $BLK_EFI $CHROOT/boot/efi + + mount $BLK_VAR $CHROOT/var + mkdir -p $CHROOT/var/lib/pkg + + mount $BLK_USR $CHROOT/usr + mkdir -p $CHROOT/usr/ports +# mount $BLK_PRT $CHROOT/usr/ports + mount $BLK_HOME $CHROOT/home + +#install_crux() { + + echo "1.1.4 Create core.lst and install pkgadd" + for p in /media/crux/core/*; do echo $p >> $CHROOT/core.lst; done + + tar xf "/media/crux/core/pkgutils#5.36-2.pkg.tar.xz" usr/bin/pkgadd -O > $CHROOT/pkgadd + + chmod +x $CHROOT/pkgadd + + echo "1.1.4 File core.lst complete, review list of packages before continue..." + read PAUSE + vim $CHROOT/core.lst + + echo "1.1.4 Starting install" + touch $CHROOT/var/lib/pkg/db + + cd $CHROOT + while read line; do + printf "Installing $line;\n" + $CHROOT/pkgadd -f -r $CHROOT $line + done < core.lst + + rm $CHROOT/pkgadd + rm $CHROOT/core.lst + + echo "1.1.5. Install extra packages;" + + mkdir $CHROOT/usr/ports/packages + cp /media/crux/core/* $CHROOT/usr/ports/packages + cp /media/crux/opt/* $CHROOT/usr/ports/packages + cp /media/crux/xorg/* $CHROOT/usr/ports/packages + + echo "Installing $CHROOT/usr/ports/packages/fakeroot#1.20.2-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/fakeroot#1.20.2-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/dbus#1.10.2-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/dbus#1.10.2-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/expat#2.1.0-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/expat#2.1.0-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/libnl#3.2.27-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libnl#3.2.27-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/libpng#1.6.19-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libpng#1.6.19-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/freetype#2.6.1-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/freetype#2.6.1-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/libffi#3.2.1-2.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libffi#3.2.1-2.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/sqlite3#3.9.2-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/sqlite3#3.9.2-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/python#2.7.10-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/python#2.7.10-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/glib#2.46.2-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/glib#2.46.2-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/grub2#2.00-7.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/grub2#2.00-7.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/grub2-efi#2.00-4.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/grub2-efi#2.00-4.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/wireless-tools#29-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/wireless-tools#29-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/wpa_supplicant#2.5-2.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/wpa_supplicant#2.5-2.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/lvm2#2.02.133-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/lvm2#2.02.133-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/mdadm#3.3.4-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/mdadm#3.3.4-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/efivar#0.21-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/efivar#0.21-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/efibootmgr#0.12-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/efibootmgr#0.12-1.pkg.tar.xz" + echo "Installing $CHROOT/usr/ports/packages/dosfstools#3.0.26-1.pkg.tar.xz" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/dosfstools#3.0.26-1.pkg.tar.xz" + + echo "1.1.6. Install extra ports;\n" + + mkdir $CHROOT/usr/ports/c9-ports + cp -r $DIR_PRT/* $CHROOT/usr/ports/c9-ports/ + + echo "1.1.7. dns resolver, copy resolv.conf;\n" + cp /etc/resolv.conf $CHROOT/etc + + echo "1.1.8. Install Handbook\n" + cp /media/crux/handbook.txt $CHROOT/root/ + + echo "1.1.9. Install Skeletons\n" + cp -r $DIR_CONF/skel $CHROOT/etc/ +#} +printf "Ready to chroot $CHROOT /bin/bash \n" diff --git a/core/scripts/ports.sh b/core/scripts/ports.sh new file mode 100644 index 0000000..a9cd901 --- /dev/null +++ b/core/scripts/ports.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +ADMIN_USER=c9admin +CHROOT=/mnt + +DIR=$(dirname "$PWD"); +DIR_CONF=$DIR"/conf" + +printf "CHROOT="$CHROOT"\n"; +printf "DIR_CONF="$DIR_CONF"\n"; + +echo "1.3.1. Build as unprivileged user;" + +chroot $CHROOT /bin/bash -c "useradd -U -m -d /usr/ports -s /bin/false pkgmk" +chroot $CHROOT /bin/bash -c "usermod -a -G pkgmk $ADMIN_USER" +chroot $CHROOT /bin/bash -c "chown -R root:pkgmk /usr/ports" +chroot $CHROOT /bin/bash -c "chmod -R 774 /usr/ports" +chroot $CHROOT /bin/bash -c "chmod 775 /usr/ports" + +echo "1.3.2. Ports Layout;" + +chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/packages" +chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/work" +chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/pkgbuild" +chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/distfiles" + +chroot $CHROOT /bin/bash -c "id pkgmk" +read PAUSE +vim $CHROOT/etc/fstab + +echo "1.3.3 Configure pkgmk;" +cp $DIR_CONF/pkgmk.conf $CHROOT/etc/ +#vim $CHROOT/etc/pkgmk.conf + +echo "1.3.4 Configure prt-get;" +mv $CHROOT/etc/ports/contrib.rsync.inactive $CHROOT/etc/ports/contrib.rsync +cp $DIR_CONF/prt-get.conf $CHROOT/etc/ +#vim $CHROOT/etc/prt-get.conf -- cgit 1.4.1-2-gfad0