From a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 12 Sep 2018 00:19:18 +0200 Subject: New multiconfig design --- common | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 common (limited to 'common') diff --git a/common b/common new file mode 100644 index 0000000..95a95fd --- /dev/null +++ b/common @@ -0,0 +1,61 @@ +# vim: ft=sh +set -e + +export MC_LOCAL_DIR="" +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + echo "Usage: $0 [OPTION]..." + echo "Multiconfig system script." + echo "$MC_DESCRIPTION" + echo + echo "Options:" + echo " --description" + echo " Print description of this module and exit." + echo " --local [DIR]" + echo " Instead of accessing remote files storage use local directory." + echo " If no directory is provided or is empty then current working directory is used." + echo " -h, --help" + echo " Print this help text and exit." + exit 0 + ;; + --description) + echo "$MC_DESCRIPTION" + exit 0 + ;; + --local) + shift + MC_LOCAL_DIR="${1:-$PWD}" + ;; + *) + echo "Unknown option: $1" >&2 + exit 1 + ;; + esac + shift +done + +if [ "$(id -u)" != "0" ]; then + die "Please run this script only as root" +fi + +# Add path to our own libraries +export PATH="$PATH:$(dirname "$(readlink -f "$0")")/lib" + +# Include utils +. utils + +# Verify if distribution is supported +[ "$(distribution)" != "unknown" ] || die "Running on unsupported distribution!" + +# Export some utility paths +export MC_STATUS_DIR="/var/multiconfig/status" +export MC_TRASH_DIR="/var/multiconfig/trash" +case "$(distribution)" in + openwrt) + MC_STATUS_DIR="/usr/share/multiconfig/status" + MC_TRASH_DIR="/usr/share/multiconfig/trash" + ;; +esac +# Make sure that status directoruy +mkdir -p "$MC_STATUS_DIR" -- cgit v1.2.3