-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher.sh
executable file
·43 lines (36 loc) · 1.06 KB
/
launcher.sh
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
#!/bin/sh
DAEMON=false
# -d is optional, doesn't need an argument
# -c is not optional, required an argument
while getopts :dc: option
do
case "${option}"
in
d) DAEMON=true;;
c) COMMAND=${OPTARG};;
esac
done
if [ $DAEMON = true ]; then
echo "Run as daemon"
COMMON_DOWNLOADS_DIR="$SNAP_COMMON/Downloads"
COMMON_CONFIGS_DIR="$SNAP_COMMON/.config/deluge"
else
echo "Run as user"
COMMON_DOWNLOADS_DIR="$SNAP_USER_COMMON/Downloads"
COMMON_CONFIGS_DIR="$SNAP_USER_COMMON/.config/deluge"
fi
# Make a common downloads folder if it doesn't exist
if [ -d "$COMMON_DOWNLOADS_DIR" ]; then
echo "$COMMON_DOWNLOADS_DIR exists already! Yay!"
else
echo "Make downloads directory: $COMMON_DOWNLOADS_DIR"
mkdir "$COMMON_DOWNLOADS_DIR"
fi
if [ -d "$COMMON_CONFIGS_DIR" ]; then
echo "$COMMON_CONFIGS_DIR exists already! Yay!"
else
echo "Make config directory in common directory: $COMMON_CONFIGS_DIR"
mkdir -p "$COMMON_CONFIGS_DIR"
fi
echo "$COMMAND" -c "$COMMON_CONFIGS_DIR/" -d
exec "$COMMAND" -c "$COMMON_CONFIGS_DIR/" -d