diff options
-rwxr-xr-x | build-debug.sh | 20 | ||||
-rwxr-xr-x | build-release.sh | 20 | ||||
-rw-r--r-- | build.sh | 48 | ||||
-rw-r--r-- | init.sh.in | 32 |
4 files changed, 60 insertions, 60 deletions
diff --git a/build-debug.sh b/build-debug.sh index 32dce03..f53d18f 100755 --- a/build-debug.sh +++ b/build-debug.sh @@ -1,21 +1,21 @@ #!/bin/sh -srcdir="`dirname "$0"`" +srcdir="$(dirname "$0")" -freebsd_version="11.1" -gnome_version="3.26.2" -gnome_underscore="3_26_2" -date="`date '+%Y%m%d'`" +freebsd_version='11.1' +gnome_version='3.26.2' +gnome_underscore='3_26_2' +date="$(date '+%Y%m%d')" # == Configurations ========================================================= -src="`pwd`/src" -root="`pwd`/root-debug" -cdroot="`pwd`/cdroot-debug" -image="`pwd`/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}-debug.iso" +src="$(pwd)/src" +root="$(pwd)/root-debug" +cdroot="$(pwd)/cdroot-debug" +image="$(pwd)/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}-debug.iso" repo="/usr/local/poudriere/data/packages/freebsd11-ports-gnome-debug" -pkgs="`cat "${srcdir}/gnome-debug-pkgs"`" +pkgs="$(cat "${srcdir}/gnome-debug-pkgs")" vol="FREEBSD_GNOME_${gnome_underscore}_DEBUG" # =========================================================================== diff --git a/build-release.sh b/build-release.sh index 349e483..9d75455 100755 --- a/build-release.sh +++ b/build-release.sh @@ -1,21 +1,21 @@ #!/bin/sh -srcdir="`dirname "$0"`" +srcdir="$(dirname "$0")" -freebsd_version="11.1" -gnome_version="3.26.2" -gnome_underscore="3_26_2" -date="`date '+%Y%m%d'`" +freebsd_version='11.1' +gnome_version='3.26.2' +gnome_underscore='3_26_2' +date="$(date '+%Y%m%d')" # == Configurations ========================================================= -src="`pwd`/src" -root="`pwd`/root-release" -cdroot="`pwd`/cdroot-release" -image="`pwd`/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}.iso" +src="$(pwd)/src" +root="$(pwd)/root-release" +cdroot="$(pwd)/cdroot-release" +image="$(pwd)/out/FreeBSD-${freebsd_version}-GNOME-${gnome_version}-${date}.iso" repo="/usr/local/poudriere/data/packages/freebsd11-ports-gnome-release" -pkgs="`cat "${srcdir}/gnome-release-pkgs"`" +pkgs="$(cat "${srcdir}/gnome-release-pkgs")" vol="FREEBSD_GNOME_${gnome_underscore}_RELEASE" # =========================================================================== @@ -1,5 +1,5 @@ steps="system packages user config ufs font uzip ramdisk boot image" -pwdir="$(realpath $(dirname "$0"))" +pwdir="$(realpath "$(dirname "$0")")" system () { install -o root -g wheel -m 755 -d "${root}" @@ -35,11 +35,11 @@ user () { #!/bin/sh set -x for user in liveuser; do - pw add user \$user -G wheel -s /bin/tcsh -M 755 - chpass -p '' \$user - install -o \$user -g \$user -m 755 -d /home/\$user - echo 'limit coredumpsize 0' > /home/\$user/.login - chown \$user:\$user /home/\$user/.login + pw add user "\$user" -G wheel -s /bin/tcsh -M 755 + chpass -p '' "\$user" + install -o "\$user" -g "\$user" -m 755 -d "/home/\$user" + echo 'limit coredumpsize 0' > "/home/\$user/.login" + chown "\$user:\$user" "/home/\$user/.login" done EOF chmod 755 "${root}/users" @@ -111,23 +111,23 @@ image () { } -if [ "`id -u`" '!=' "0" ]; then - echo "Sorry, you are not root ..." +if [ "$(id -u)" '!=' '0' ]; then + echo 'Sorry, you are not root ...' exit 1 fi # This check cannot be done reliably, but it should be able to catch the # most common mistake. -if [ "$(basename "$0")" = "build.sh" ] && [ "${pwdir}" = "$(realpath $(pwd))" ]; then - echo "This script cannot be run directly." - echo "Please create a wrapper script that sources this file instead." - echo "You can use build-release.sh and build-debug.sh as examples." +if [ "$(basename "$0")" = 'build.sh' ] && [ "${pwdir}" = "$(realpath "$(pwd)")" ]; then + echo 'This script cannot be run directly.' + echo 'Please create a wrapper script that sources this file instead.' + echo 'You can use build-release.sh and build-debug.sh as examples.' exit 1 fi # Check whether required variables are defined. assert_dir_or_file () { - if [ -z "$2" ] || [ "$(realpath "$2" 2>/dev/null)" = "/" ]; then + if [ -z "$2" ] || [ "$(realpath "$2" 2>/dev/null)" = '/' ]; then echo "Variable '$1' is unset or set to the root directory." exit 1 fi @@ -162,39 +162,39 @@ if [ "${#vol}" -gt "31" ]; then exit 1 fi -printf "All steps: \033[1;33m%s\033[m\n" "${steps}" -printf "(E)dit or (R)un? " -read edit_or_run +printf 'All steps: \033[1;33m%s\033[m\n' "${steps}" +printf '(E)dit or (R)un? ' +read -r edit_or_run case "${edit_or_run}" in E*|e*) - printf "New steps: " - read steps + printf 'New steps: ' + read -r steps ;; R*|r*) ;; *) - echo "Unknown action ..." + echo 'Unknown action ...' exit 1 ;; esac for task in ${steps}; do if type "${task}" >/dev/null 2>/dev/null; then :; else - printf "==> Task \033[1;31m%s\033[m not found\n" "${task}" + printf '==> Task \033[1;31m%s\033[m not found\n' "${task}" exit 1 fi done for task in ${steps}; do - printf "==> Running task \033[1;33m%s\033[m\n" "${task}" + printf '==> Running task \033[1;33m%s\033[m\n' "${task}" set -x - if ${task}; then + if "${task}"; then set +x - printf "=> Task \033[1;32m%s\033[m OK\n" "${task}" + printf '=> Task \033[1;32m%s\033[m OK\n' "${task}" else set +x - printf "=> Task \033[1;31m%s\033[m failed\n" "${task}" + printf '=> Task \033[1;31m%s\033[m failed\n' "${task}" exit 1 fi done @@ -1,43 +1,43 @@ #!/bin/sh -PATH="/rescue" +PATH='/rescue' -if [ "`ps -o command 1 | tail -n 1 | ( read c o; echo ${o} )`" = "-s" ]; then - echo "==> Running in single-user mode" - SINGLE_USER="true" +if [ "$(ps -o command 1 | tail -n 1 | ( read -r _ o; printf %s "$o" ))" = "-s" ]; then + echo '==> Running in single-user mode' + SINGLE_USER='true' fi -echo "==> Remount rootfs as read-write" +echo '==> Remount rootfs as read-write' mount -u -w / -echo "==> Make mountpoints" +echo '==> Make mountpoints' mkdir -p /cdrom /memdisk /sysroot -echo "==> Mount cdrom" +echo '==> Mount cdrom' mount_cd9660 /dev/iso9660/@VOLUME@ /cdrom mdmfs -P -F /cdrom/data/system.uzip -o ro md.uzip /sysroot -if [ "$SINGLE_USER" = "true" ]; then - echo -n "Enter memdisk size used for read-write access in the live system: " - read MEMDISK_SIZE +if [ "$SINGLE_USER" = 'true' ]; then + echo -n 'Enter memdisk size used for read-write access in the live system: ' + read -r MEMDISK_SIZE else - MEMDISK_SIZE="256" + MEMDISK_SIZE='256' fi -echo "==> Mount swap-based memdisk" +echo '==> Mount swap-based memdisk' mdmfs -s "${MEMDISK_SIZE}m" md /memdisk || exit 1 mount -t unionfs /memdisk /sysroot mkdir -p /sysroot/mnt/cdrom mount_nullfs -o ro /cdrom /sysroot/mnt/cdrom -echo "==> Mount devfs" +echo '==> Mount devfs' mount -t devfs devfs /sysroot/dev -if [ "$SINGLE_USER" = "true" ]; then - echo "Starting interactive shell in temporary rootfs ..." +if [ "$SINGLE_USER" = 'true' ]; then + echo 'Starting interactive shell in temporary rootfs ...' sh fi -kenv init_shell="/bin/sh" +kenv init_shell='/bin/sh' exit 0 |