everest-build-tools/tools/prep
2023-04-27 08:14:01 -04:00

59 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
TARGET_DIR=${2}
usage() {
printf "${0} - prepare a directory for system image creation\n"
printf "usage: ${0} [-h] [-v] [-d] DIRECTORY\n"
printf "\n"
printf "${0} {-h --help} Show this message\n"
printf "${0} {-v --version} Show the version\n"
printf "${0} {-d --dir} Prepare a directory\n"
printf "\n"
printf "prep is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
usage_small () {
printf "usage: ${0} [-h] [-v] [-d] DIRECTORY\n"
}
check_for_root() {
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "${0} must be run as root\n"
exit 1
fi
}
change_ownership() {
chown -Rv root:root ${2}
chgrp -v 13 ${2}/var/log/lastlog
}
case ${1} in
-h|--help)
usage "$@"
exit 0
;;
-v|--version)
printf "prep v1.0.0\n"
printf "everest-build-tools v1.0.0\n"
exit 0
;;
-d|--dir)
check_for_root "$@"
if [[ "${2}" == "" ]]; then
printf "No directory specified\n"
exit 1
fi
change_ownership "$@"
;;
*)
usage_small "$@"
exit 1
esac
usage_small "$@"
exit 1