forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecks.sh
More file actions
executable file
·56 lines (50 loc) · 1.19 KB
/
checks.sh
File metadata and controls
executable file
·56 lines (50 loc) · 1.19 KB
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
#!/bin/sh
echo "checking preconditions..."
checks_failed=0
check_failed()
{
checks_failed=$((checks_failed + 1))
}
check_if_writable()
{
# checks if the given dir is writable, if it exists
# it's ok if the dir does not exist at all, because it will be created
# during solid server startup then and have the correct permissions
dir=$1
if [ -d "${dir}" ]; then
if [ -w "${dir}" ]; then
echo "✓ ${dir} is accessible by $(whoami)"
else
echo "✗ ${dir} not writable by $(whoami)"
check_failed
fi
fi
}
check_if_file_readable()
{
# checks if the given file exists and is readable
file=$1
if [ -e "${file}" ]; then
if [ -r "${file}" ]; then
echo "✓ ${file} is accessible by $(whoami)"
else
echo "✗ ${file} not readable by $(whoami)"
check_failed
fi
else
echo "✗ ${file} does not exist"
check_failed
fi
}
check_if_writable "${SOLID_HOME}/config"
check_if_writable "${SOLID_HOME}/data"
check_if_writable "${SOLID_HOME}/.db"
check_if_file_readable "${SOLID_SSL_KEY}"
check_if_file_readable "${SOLID_SSL_CERT}"
if [ "$checks_failed" -gt 0 ]; then
echo "Finished: ERROR"
exit 1
else
echo "Finished: SUCCESS"
exit 0;
fi