aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-09-12 00:19:18 +0200
committerKarel Kočí <cynerd@email.cz>2018-09-12 00:19:18 +0200
commita8bfe6abb693150e9ee01ea6e8d672fc074d1f1c (patch)
treec5e6cc5166c56ad45a396d9af6d4063ad755d9d5 /common
parent4e4d389127254c7404bc71a308129966bd9a8b07 (diff)
downloadmulticonfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.tar.gz
multiconfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.tar.bz2
multiconfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.zip
New multiconfig design
Diffstat (limited to 'common')
-rw-r--r--common61
1 files changed, 61 insertions, 0 deletions
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"