aboutsummaryrefslogtreecommitdiff
path: root/common
blob: 95a95fd0976b147c76f4de5093d16a03e35a50cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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"