diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-03-24 11:09:13 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-03-24 11:09:13 -0500 |
commit | 4e2baae45edab2b18b29f0732ac46ca56bf9e96b (patch) | |
tree | 0a2cb6607cbcf61d09e79819bc76b29587bda0fb | |
parent | 48c0449eca92fdfb2ebb980fef779642effc28cd (diff) |
Call inside root with an argument. 7 for chapter 7. Chapter 7 commands exit with status 7.
-rw-r--r-- | insidechroot.sh | 225 |
1 files changed, 117 insertions, 108 deletions
diff --git a/insidechroot.sh b/insidechroot.sh index 784a40e..1863531 100644 --- a/insidechroot.sh +++ b/insidechroot.sh @@ -1,97 +1,100 @@ #!/bin/bash +CHAPTER="$1" + source /sources/colors.sh source /sources/spinner.sh printf "%b" "${CYN}SUCCESSFULLY ENTERED ${RED}CHROOT${RST}!\n" -printf "%b" "${GRN}Creating directories...${RST}\n" -if [ -f /sources/createdirs ]; then - printf "%b" "${GRN} Directories already created.${RST}\n" -else - mkdir -p /boot - mkdir -p /home - mkdir -p /mnt - mkdir -p /opt - mkdir -p /srv - - mkdir -p /etc/opt - mkdir -p /etc/opt/sysconfig - mkdir -p /lib/firmware - mkdir -p /media/floppy - mkdir -p /media/cdrom - mkdir -p /usr/bin - mkdir -p /usr/include - mkdir -p /usr/lib - mkdir -p /usr/sbin - mkdir -p /usr/src - mkdir -p /usr/local/bin - mkdir -p /usr/local/include - mkdir -p /usr/local/lib - mkdir -p /usr/local/sbin - mkdir -p /usr/local/src - mkdir -p /usr/share/color - mkdir -p /usr/share/dict - mkdir -p /usr/share/doc - mkdir -p /usr/share/info - mkdir -p /usr/share/locale - mkdir -p /usr/share/man - mkdir -p /usr/share/man/man1 - mkdir -p /usr/share/man/man2 - mkdir -p /usr/share/man/man3 - mkdir -p /usr/share/man/man4 - mkdir -p /usr/share/man/man5 - mkdir -p /usr/share/man/man6 - mkdir -p /usr/share/man/man7 - mkdir -p /usr/share/man/man8 - mkdir -p /usr/share/misc - mkdir -p /usr/share/terminfo - mkdir -p /usr/share/zoneinfo - mkdir -p /usr/local/share/color - mkdir -p /usr/local/share/dict - mkdir -p /usr/local/share/doc - mkdir -p /usr/local/share/info - mkdir -p /usr/local/share/locale - mkdir -p /usr/local/share/man - mkdir -p /usr/local/share/man/man1 - mkdir -p /usr/local/share/man/man2 - mkdir -p /usr/local/share/man/man3 - mkdir -p /usr/local/share/man/man4 - mkdir -p /usr/local/share/man/man5 - mkdir -p /usr/local/share/man/man6 - mkdir -p /usr/local/share/man/man7 - mkdir -p /usr/local/share/man/man8 - mkdir -p /usr/local/share/misc - mkdir -p /usr/local/share/terminfo - mkdir -p /usr/local/share/zoneinfo - mkdir -p /var/cache - mkdir -p /var/local - mkdir -p /var/log - mkdir -p /var/mail - mkdir -p /var/opt - mkdir -p /var/spool - mkdir -p /var/lib/color - mkdir -p /var/lib/misc - mkdir -p /var/lib/locate - - ln -sf /run /var/run - ln -sf /run/lock /var/lock - - install -d -m 0750 /root - install -d -m 1777 /tmp /var/tmp - - printf "%b" " ${GRN}Directories created${RST}\n" - touch /sources/createdirs -fi +if [ "${CHAPTER}" -eq 7 ]; then + printf "%b" "${GRN}Creating directories...${RST}\n" + if [ -f /sources/createdirs ]; then + printf "%b" "${GRN} Directories already created.${RST}\n" + else + mkdir -p /boot + mkdir -p /home + mkdir -p /mnt + mkdir -p /opt + mkdir -p /srv -printf "%b" "${GRN}Creating essential files and symbolic links... ${RST}\n" -if [ -f "/sources/symfiles" ]; then - printf "%b" " ${GRN}Files and symbolic links already created.${RST}\n" -else - ln -sf /proc/self/mounts /etc/mtab - echo "127.0.0.1 localhost $(hostname)" > /etc/hosts + mkdir -p /etc/opt + mkdir -p /etc/opt/sysconfig + mkdir -p /lib/firmware + mkdir -p /media/floppy + mkdir -p /media/cdrom + mkdir -p /usr/bin + mkdir -p /usr/include + mkdir -p /usr/lib + mkdir -p /usr/sbin + mkdir -p /usr/src + mkdir -p /usr/local/bin + mkdir -p /usr/local/include + mkdir -p /usr/local/lib + mkdir -p /usr/local/sbin + mkdir -p /usr/local/src + mkdir -p /usr/share/color + mkdir -p /usr/share/dict + mkdir -p /usr/share/doc + mkdir -p /usr/share/info + mkdir -p /usr/share/locale + mkdir -p /usr/share/man + mkdir -p /usr/share/man/man1 + mkdir -p /usr/share/man/man2 + mkdir -p /usr/share/man/man3 + mkdir -p /usr/share/man/man4 + mkdir -p /usr/share/man/man5 + mkdir -p /usr/share/man/man6 + mkdir -p /usr/share/man/man7 + mkdir -p /usr/share/man/man8 + mkdir -p /usr/share/misc + mkdir -p /usr/share/terminfo + mkdir -p /usr/share/zoneinfo + mkdir -p /usr/local/share/color + mkdir -p /usr/local/share/dict + mkdir -p /usr/local/share/doc + mkdir -p /usr/local/share/info + mkdir -p /usr/local/share/locale + mkdir -p /usr/local/share/man + mkdir -p /usr/local/share/man/man1 + mkdir -p /usr/local/share/man/man2 + mkdir -p /usr/local/share/man/man3 + mkdir -p /usr/local/share/man/man4 + mkdir -p /usr/local/share/man/man5 + mkdir -p /usr/local/share/man/man6 + mkdir -p /usr/local/share/man/man7 + mkdir -p /usr/local/share/man/man8 + mkdir -p /usr/local/share/misc + mkdir -p /usr/local/share/terminfo + mkdir -p /usr/local/share/zoneinfo + mkdir -p /var/cache + mkdir -p /var/local + mkdir -p /var/log + mkdir -p /var/mail + mkdir -p /var/opt + mkdir -p /var/spool + mkdir -p /var/lib/color + mkdir -p /var/lib/misc + mkdir -p /var/lib/locate + + ln -sf /run /var/run + ln -sf /run/lock /var/lock + + install -d -m 0750 /root + install -d -m 1777 /tmp /var/tmp + + printf "%b" " ${GRN}Directories created${RST}\n" + touch /sources/createdirs + fi - cat > /etc/passwd << "EOF" + printf "%b" "${GRN}Creating essential files and symbolic links... ${RST}\n" + if [ -f "/sources/symfiles" ]; then + printf "%b" " ${GRN}Files and symbolic links already created.${RST}\n" + else + ln -sf /proc/self/mounts /etc/mtab + echo "127.0.0.1 localhost $(hostname)" > /etc/hosts + + cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/dev/null:/bin/false daemon:x:6:6:Daemon User:/dev/null:/bin/false @@ -100,7 +103,7 @@ uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false nobody:x:99:99:Unprivileged User:/dev/null:/bin/false EOF - cat > /etc/group << "EOF" + cat > /etc/group << "EOF" root:x:0: bin:x:1:daemon sys:x:2: @@ -128,29 +131,35 @@ nogroup:x:99: users:x:999: EOF - echo "tester:x:$(ls -n "$(tty)" | cut -d" " -f3):101::/home/tester:/bin/bash" >> /etc/passwd - echo "tester:x:101:" >> /etc/group - install -o tester -d /home/tester + echo "tester:x:$(ls -n "$(tty)" | cut -d" " -f3):101::/home/tester:/bin/bash" >> /etc/passwd + echo "tester:x:101:" >> /etc/group + install -o tester -d /home/tester - touch /var/log/btmp - touch /var/log/lastlog - touch /var/log/faillog - touch /var/log/tmp - chgrp utmp /var/log/lastlog - chmod 664 /var/log/lastlog - chmod 600 /var/log/btmp + touch /var/log/btmp + touch /var/log/lastlog + touch /var/log/faillog + touch /var/log/tmp + chgrp utmp /var/log/lastlog + chmod 664 /var/log/lastlog + chmod 600 /var/log/btmp - echo -e " ${GRN}Files and symlinks created.${RST}" - touch /sources/symfiles -fi + echo -e " ${GRN}Files and symlinks created.${RST}" + touch /sources/symfiles + fi + + cd /sources || exit 1 -cd /sources || exit 1 + # Chapter 7 + for package in libstdc++ gettext bison perl python texinfo util-linux; do + source packageinstall.sh 7 $package + retval=$? + if [ "$retval" -ne 0 ]; then + exit 1 + fi + done + + exit 7 +else + printf "%b" "Do Chapter 8, 9 and 10 stuff here.\n" +fi -# Chapter 7 -for package in libstdc++ gettext bison perl python texinfo util-linux; do - source packageinstall.sh 7 $package - retval=$? - if [ "$retval" -ne 0 ]; then - exit 1 - fi -done |