This repository has been archived by the owner on Apr 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-run.sh
executable file
·89 lines (76 loc) · 2.37 KB
/
docker-run.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
function load_configuration()
{
configuration_file='config/paperyard'
if [ -r ${configuration_file} ]; then
while IFS='=' read lhs rhs
do
if [[ ! $lhs =~ ^\ *# && -n $lhs ]]; then
rhs="${rhs%%\#*}" # Del in line right comments
rhs="${rhs%%*( )}" # Del trailing spaces
rhs="${rhs%\"*}" # Del opening string quotes
rhs="${rhs#\"*}" # Del closing string quotes
eval "${lhs}='${rhs}'"
fi
done < <(envsubst < $configuration_file)
else
echo 'No configuration found. Will load defaults.'
fi
}
function load_defaults()
{
: ${paperyard_root:=$HOME/Paperyard/}
: ${paperyard_scan:=scan/}
: ${paperyard_inbox:=inbox/}
: ${paperyard_outbox:=outbox/}
: ${paperyard_sort:=sort/}
: ${paperyard_database:=data/database/}
: ${paperyard_port:=80}
: ${paperyard_development:=false}
}
function start_development()
{
docker run --name ppyrd --rm \
-v "$(pwd)/paperyard:/var/www/html/" \
-v "${paperyard_root}/${paperyard_database}:/data/database" \
-v "${paperyard_root}/${paperyard_scan}:/data/scan" \
-v "${paperyard_root}/${paperyard_inbox}:/data/inbox" \
-v "${paperyard_root}/${paperyard_outbox}:/data/outbox" \
-v "${paperyard_root}/${paperyard_sort}:/data/sort" \
-p "${paperyard_port}:80" \
-e COMMIT_COUNT=$(git rev-list --count MASTER) \
-i -t ppyrd_image
}
function start_production()
{
docker run --name ppyrd --rm \
-v "${paperyard_root}/${paperyard_database}:/data/database" \
-v "${paperyard_root}/${paperyard_scan}:/data/scan" \
-v "${paperyard_root}/${paperyard_inbox}:/data/inbox" \
-v "${paperyard_root}/${paperyard_outbox}:/data/outbox" \
-v "${paperyard_root}/${paperyard_sort}:/data/sort" \
-p "${paperyard_port}:80" \
-i -t ppyrd_image
}
function splash()
{
echo 'Paperyard'
if ${paperyard_development}; then
echo 'Environment: development'
else
echo 'Environment: production'
fi
echo "Port: ${paperyard_port}"
}
function main()
{
load_configuration
load_defaults
splash
if ${paperyard_development}; then
start_development
else
start_production
fi
}
main