Fixes for tar generation

This commit is contained in:
dev 2016-08-30 14:20:55 -05:00
parent e82614a279
commit 5ea18518ef
2 changed files with 84 additions and 25 deletions

View File

@ -5,8 +5,17 @@ echoroot:
@echo ${HTTPROOT} @echo ${HTTPROOT}
@echo ${HTTPUSER} @echo ${HTTPUSER}
compile:
@echo Nothing to do.
install: script webpresent install: script webpresent
test:
./shadowarch -h
reverse:
cp ${HTTPROOT}/shadowarch .
webpresent: shadowarch webpresent: shadowarch
/root/bin/shadowarch-tar-gen /root/bin/shadowarch-tar-gen
cp ./shadowarch ${HTTPROOT} cp ./shadowarch ${HTTPROOT}
@ -17,7 +26,4 @@ script: shadowarch-tar-gen
chmod 0700 /root/bin/shadowarch-tar-gen chmod 0700 /root/bin/shadowarch-tar-gen
chown root:root /root/bin/shadowarch-tar-gen chown root:root /root/bin/shadowarch-tar-gen
configure:
vim Makefile

View File

@ -8,24 +8,34 @@ function header () {
return return
} }
function help() { function help() {
echo Usage: ${0} '[-s] [-e]' echo Usage: ${0} '[-d /dev/somedisk] [-e] [-g] [-p] [-s]'
echo '\-s Create a layout for an AniNIX::Spartacus' echo " ${0}" '-h'
echo '\-e Encrypt the root partition' echo '-d Specify disk to install to.'
echo '-e Encrypt the root partition'
echo '-g Add GUI packages'
echo '-h Get help'
echo '-p Add productivity packages'
echo '-s Create a layout for an AniNIX::Spartacus'
exit 1; exit 1;
} }
spartacus=0; spartacus=0;
encrypt=0; encrypt=0;
gui=0;
productivity=0;
disk="/dev/sda" disk="/dev/sda"
bootpart=1; bootpart=1;
rootpart=2; rootpart=2;
datapart=99; datapart=99;
while getopts "sed:" OPTION # TODO Add LVM as an argument
while getopts "ed:ghps" OPTION
do do
case $OPTION in case $OPTION in
s) spartacus=1 ;;
e) encrypt=1 ;; e) encrypt=1 ;;
d) disk=${OPTARG} ;; d) disk=${OPTARG} ;;
g) gui=1 ;;
p) productivity=1; gui=1 ;;
s) spartacus=1 ;;
*) help *) help
esac esac
done done
@ -33,6 +43,8 @@ done
header Confirm options: header Confirm options:
echo Spartacus set to: $spartacus echo Spartacus set to: $spartacus
echo Encryption set to: $encrypt echo Encryption set to: $encrypt
echo GUI: $gui
echo Productivity: $productivity
echo Disk to use: $disk echo Disk to use: $disk
printf "Is this OK? Type YES to continue: " printf "Is this OK? Type YES to continue: "
read answer read answer
@ -40,11 +52,9 @@ if [ "$answer" != "YES" ]; then
echo User did not confirm. echo User did not confirm.
exit 1; exit 1;
fi fi
pacman -Syy
## REMOVE this section to not format the first disk. You will have to layout your own space. ##
header Allocating space header Allocating space
shred -n 1 -v --random-source=/dev/zero "$disk" dd if=/dev/zero of="$disk" bs=1 count=2000000 # "$(fdisk -l "$disk" | head -n 1 | cut -f 5 -d ' ')"
if [ $spartacus -eq 1 ]; then if [ $spartacus -eq 1 ]; then
# Insert an ExFAT data partition ahead of the rest. # Insert an ExFAT data partition ahead of the rest.
export datapart=1; export datapart=1;
@ -58,7 +68,7 @@ if [ $spartacus -eq 1 ]; then
export datasize=$(($disksize / 2)) export datasize=$(($disksize / 2))
printf 'mklabel msdos\nmkpart primary ext4 1MiB %s\nmkpart primary ext4 %s %s\nmkpart primary ext4 %s 100%%FREE\nprint\nquit\n' $datasize"MiB" $datasize"MiB" $(($datasize+$bootsize))"MiB" $(($datasize+$bootsize))"MiB" | parted "$disk" printf 'mklabel msdos\nmkpart primary ext4 1MiB %s\nmkpart primary ext4 %s %s\nmkpart primary ext4 %s 100%%FREE\nprint\nquit\n' $datasize"MiB" $datasize"MiB" $(($datasize+$bootsize))"MiB" $(($datasize+$bootsize))"MiB" | parted "$disk"
#create data partition #create data partition
pacman -Sy exfat-utils --noconfirm pacman -S exfat-utils --noconfirm
mkfs.exfat "$disk""$datapart" mkfs.exfat "$disk""$datapart"
exfatlabel "$disk""$datapart" "AS-XPLATFRM" exfatlabel "$disk""$datapart" "AS-XPLATFRM"
else else
@ -78,32 +88,44 @@ if [ $encrypt -eq 1 ]; then
cryptsetup luksFormat -c serpent-xts-plain64 -h sha512 --key-size 512 "$disk""$rootpart" cryptsetup luksFormat -c serpent-xts-plain64 -h sha512 --key-size 512 "$disk""$rootpart"
header Unlocking root header Unlocking root
cryptsetup luksOpen "$disk""$rootpart" cryptroot cryptsetup luksOpen "$disk""$rootpart" cryptroot
mkfs.xfs /dev/mapper/cryptroot mkfs.xfs -f /dev/mapper/cryptroot
xfs_admin -L ROOT /dev/mapper/cryptroot xfs_admin -L ROOT /dev/mapper/cryptroot
mount /dev/mapper/cryptroot /mnt mount /dev/mapper/cryptroot /mnt
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
else else
header Making root on "$disk""$rootpart" header Making root on "$disk""$rootpart"
mkfs.xfs "$disk""$rootpart" mkfs.xfs -f "$disk""$rootpart"
xfs_admin -L ROOT "$disk""$rootpart" xfs_admin -L ROOT "$disk""$rootpart"
mount "$disk""$rootpart" /mnt mount "$disk""$rootpart" /mnt
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
fi fi
mkdir /mnt/boot mkdir /mnt/boot
mount "$disk""$bootpart" /mnt/boot mount "$disk""$bootpart" /mnt/boot
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
## END REMOVE ##
# Install ArchLinux with basic clients for the AniNIX Services. # Install ArchLinux with basic clients for the AniNIX Services.
# * git for AniNIX::Bazaar # * git for Foundation
# * lynx for WebServer and Wiki # * lynx for WebServer and Wiki
# * openssh for SSH/SFTP # * openssh for SSH/SFTP
# * irssi for IRC # * irssi for IRC
# * make for source packages # * make for source packages
# * tor for anonymity # * tor for anonymity
# Uncomment the remaining packages for a desktop environment.
header Installing ArchLinux to root header Installing ArchLinux to root
yes "" | pacstrap -i /mnt base base-devel grub efibootmgr openssh git make lynx irssi vim wget tor torsocks # xorg-server xfce4 seamonkey export pkglist="base base-devel parted net-tools bind-tools git openssh make lynx irssi vim wget tor torsocks grub os-prober"
if [ $gui -eq 1 ]; then
export pkglist="$pkglist"" xorg-server xfce4 seamonkey conky"
fi
if [ $spartacus -eq 1 ]; then
export pkglist="$pkglist"" exfat-utils"
fi
if [ $productivity -eq 1 ]; then
export pkglist="$pkglist"" libreoffice-still gimp feh vlc evince"
fi
yes "" | pacstrap -i /mnt $pkglist
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
header Create FSTAB header Create FSTAB
genfstab -U /mnt >> /mnt/etc/fstab genfstab -U /mnt >> /mnt/etc/fstab
@ -114,15 +136,19 @@ ln -s /usr/share/zoneinfo/America/Chicago /mnt/etc/localtime
arch-chroot /mnt hwclock --systohc --utc arch-chroot /mnt hwclock --systohc --utc
header Setup bootloader header Setup bootloader
export rootuuid="$(blkid "$disk""$rootpart" | cut -f 2 -d '"')"
if [ $encrypt -eq 1 ]; then if [ $encrypt -eq 1 ]; then
export hookstring="$(grep 'HOOKS=' /mnt/etc/mkinitcpio.conf | grep -v '#')" export hookstring="$(grep 'HOOKS=' /mnt/etc/mkinitcpio.conf | grep -v '#')"
sed -i 's#'"$hookstring"'#HOOKS="base udev autodetect modconf block encrypt filesystems keyboard fsck"#' /mnt/etc/mkinitcpio.conf sed -i 's#'"$hookstring"'#HOOKS="base udev autodetect modconf block encrypt filesystems keyboard fsck"#' /mnt/etc/mkinitcpio.conf
export rootuuid="$(blkid "$disk""$rootpart" | cut -f 2 -d '"')" sed -i 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="cryptdevice=UUID='$rootuuid':cryptroot"#' /mnt/etc/default/grub
sed -i 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="cryptdevice=UUID='$rootuuid':cryptroot root=/dev/mapper/cryptroot"' /etc/default/grub
fi fi
arch-chroot /mnt mkinitcpio -p linux arch-chroot /mnt mkinitcpio -p linux
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
arch-chroot /mnt grub-install --target=i386-pc "$disk" arch-chroot /mnt grub-install --target=i386-pc "$disk"
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub-cfg if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
if [ $? -ne 0 ]; then header ERROR: Cannot continue; exit 1; fi
header Set networking header Set networking
arch-chroot /mnt systemctl enable netctl arch-chroot /mnt systemctl enable netctl
@ -136,17 +162,44 @@ arch-chroot /mnt netctl enable $interface
# Set prompt and vimrc for ShadowArch # Set prompt and vimrc for ShadowArch
header Setting ShadowArch customizations. header Setting ShadowArch customizations.
echo 'PS1="\[\033[00;31m\][ AniNIX::\h(\[\033[01;32m\]ShadowArch\[\033[00;31m\]) \[\033[00;36m\]\u \[\033[01;37m\]\d \T \[\033[00;35m\]\w\[\033[00;31m\] ] \n|\[\033[m\]> "' >> /mnt/etc/bash.bashrc echo 'PS1="\[\033[00;31m\][ AniNIX::\h(\[\033[01;32m\]ShadowArch\[\033[00;31m\]) \[\033[00;36m\]\u \[\033[01;37m\]\d \T \[\033[00;35m\]\w\[\033[00;31m\] ] \n|\[\033[m\]> "' >> /mnt/etc/bash.bashrc
# TODO Find a way to set the terminal header properly
#for i in $(grep PROMPT_COMMAND /mnt/etc/bash.bashrc); do
# sed -i 's/'"$i"'/PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'"'"'printf "\033]0;AniNIX::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'"'"'/g' /etc/bash.bashrc
#done
sed -i '/PS1=/d' /mnt/etc/skel/.bashrc sed -i '/PS1=/d' /mnt/etc/skel/.bashrc
cd /mnt/etc/ cd /mnt/etc/
wget https://aninix.net/shadowarch.tar wget https://aninix.net/shadowarch.tar
rm -Rf /etc/skel /etc/vimrc rm -Rf ./skel ./vimrc
tar xvf shadowarch.tar tar xvf /mnt/etc/shadowarch.tar
cd /mnt/root
tar xvf /mnt/etc/shadowarch.tar
rm shadowarch.tar rm shadowarch.tar
ln -s /etc/skel/.bashrc /mnt/root/.bashrc
# Set hostname
header Set hostname
printf "What is your hostname? AniNIX::"
read hostname
echo "$hostname" > /mnt/etc/hostname
# Set password # Set password
header Set new root passphrase header Set new root passphrase
arch-chroot /mnt passwd arch-chroot /mnt passwd
# Clone ConfigPackags from AniNIX::Foundation
arch-chroot /mnt git -C /usr/local/src/ clone https://aninix.net/foundation/ConfigPackages
if [ $gui -eq 1 ]; then
echo "Remember to install your graphics drivers!
For NVidia, look at xf86-video-nouveau
For AMD, look at xf86-video-amdgpu
For Hyper-V, look at xf86-video-fbdev
For Virtual Box, look at virtualbox-guest-utils
For VMware, look at open-vm-tools"
fi
header Installed ShadowArch! Press enter to reboot. header Installed ShadowArch! Press enter to reboot.
read read