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

81 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# mkskel - create a filesystem layout
# (C) 2023 Everest Linux
# See the GNU GPL Version 3 for copyright details
ROOT_DIR=${2}
mkdirs() {
mkdir -pv ${ROOT_DIR}/{dev,home,mnt,proc,run,srv,sys,boot,etc,lost+found}
mkdir -pv ${ROOT_DIR}/{opt,root,var,tmp,include,share}
mkdir -pv ${ROOT_DIR}/glacier
for DIR in bin lib sbin; do
mkdir -pv ${ROOT_DIR}/${DIR}
mkdir -pv ${ROOT_DIR}/usr/${DIR}
done
case $(uname -m) in
x86_64)
ln -sv ${ROOT_DIR}/lib ${ROOT_DIR}/lib64
ln -sv ${ROOT_DIR}/usr/lib ${ROOT_DIR}/usr/lib64
;;
esac
mkdir -pv ${ROOT_DIR}/rescue
mkdir -pv ${ROOT_DIR}/rescue/{dev,mnt,proc,run,etc,lost+found}
mkdir -pv ${ROOT_DIR}/rescue/{root,var,tmp}
for DIR in bin lib sbin; do
mkdir -pv ${ROOT_DIR}/rescue/${DIR}
done
case $(uname -m) in
x86_64)
ln -sv ${ROOT_DIR}/rescue/lib ${ROOT_DIR}/rescue/lib64
;;
esac
}
helpmsg() {
printf "usage: ${0} [-h] [-d] DIRECTORY\n"
}
helpmsg_big() {
printf "${0} - create a filesystem layout\n"
printf "usage: ${0} [-h] [-d] DIRECTORY\n"
printf "\n"
printf "${0} {-h} Show this message\n"
printf "${0} {-d DIRECTORY} Create a filesystem layout in DIRECTORY\n"
printf "\n"
printf "This program is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
case $1 in
-h)
helpmsg_big "$@"
exit 0
;;
-d)
if [ "${2}" == "" ]; then
printf "you must specify a directory\n"
exit 1
fi
mkdirs "$@"
exit 0
;;
-*)
helpmsg "$@"
exit 1
;;
*)
helpmsg "$@"
exit 1
esac
helpmsg "$@"
exit 1