diff --git a/bin/portzap b/bin/portzap index 4abbaa0..0d78618 100755 --- a/bin/portzap +++ b/bin/portzap @@ -13,7 +13,7 @@ libexec=$(realpath "${rootdir}/../libexec/portzap") ## # Functions require_root() { - if [ $(id -u) -ne 0 ]; then + if [ "$(id -u)" != "0" ]; then echo "This command requires root privileges." exit 1 fi @@ -44,29 +44,29 @@ case $1 in "clone") require_dependency git require_membership_of _portzap - ${libexec}/portzap-clone "${giturl}" "${gitdir}" + "${libexec}"/portzap-clone "${giturl}" "${gitdir}" ;; "pull") require_dependency git require_membership_of _portzap - ${libexec}/portzap-pull "${gitdir}" + "${libexec}"/portzap-pull "${gitdir}" ;; "install") require_root require_dependency git - ${libexec}/portzap-install "${gitdir}" "${installdir}" "${revision}" + "${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}" ;; "adduser") require_root - ${libexec}/portzap-adduser + "${libexec}"/portzap-adduser ;; *) - echo Usage: portzap COMMAND [OPTIONS] - echo - echo Commands: - echo -e " clone Clone the hardenedbsd ports tree." - echo -e " pull Pull updates from the hardenedbsd ports tree." - echo -e " install Install the ports tree into /usr/ports." - echo -e " adduser Add the portzap user, group and home directory." + printf "Usage: portzap COMMAND [OPTIONS]\n" + printf "\n" + printf "Commands:\n" + printf " clone Clone the hardenedbsd ports tree.\n" + printf " pull Pull updates from the hardenedbsd ports tree.\n" + printf " install Install the ports tree into /usr/ports.\n" + printf " adduser Add the portzap user, group and home directory.\n" ;; esac diff --git a/libexec/portzap/portzap-install b/libexec/portzap/portzap-install index 8fe37d9..6c504ce 100755 --- a/libexec/portzap/portzap-install +++ b/libexec/portzap/portzap-install @@ -2,15 +2,14 @@ set -ex gitdir=$1 installdir=$2 -revision=$3 excludes=".git .gitignore .hooks .arcconfig" -cd ${gitdir} +cd "${gitdir}" find -s . -maxdepth 1 \ - -exec cp -Rfv {} ${installdir} \; \ - -exec chown -R root:_portzap ${installdir}/{} \; \ - -exec chmod -R u=rwX,g=rwX,o= ${installdir}/{} \; -cd ${installdir} + -exec cp -Rfv {} "${installdir}" \; \ + -exec chown -R root:_portzap "${installdir}/{}" \; \ + -exec chmod -R u=rwX,g=rwX,o= "${installdir}/{}" \; +cd "${installdir}" for exclude in ${excludes}; do - rm -rf ${exclude} + rm -rf "${exclude}" done diff --git a/libexec/portzap/portzap-pull b/libexec/portzap/portzap-pull index 9dcf4ad..9af285d 100755 --- a/libexec/portzap/portzap-pull +++ b/libexec/portzap/portzap-pull @@ -1,7 +1,7 @@ #!/bin/sh set -ex gitdir=$1 -umask=rwX,g=rwX,o= +umask rwX,g=rwX,o= if [ -e "${gitdir}/.git" ]; then cd "${gitdir}" git pull --rebase origin hardenedbsd/main