-
Notifications
You must be signed in to change notification settings - Fork 101
/
get-config-dir
executable file
·62 lines (51 loc) · 1.79 KB
/
get-config-dir
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
#!/bin/bash
#
# (c) 2006 Henning Glawe <glaweh@debian.org>
# (c) 2009-2011 Thomas Lange <lange@debian.org>
### BEGIN SUBROUTINE INFO
# Provides-Var:
# Requires-Var: $FAI_CONFIG_SRC $FAI
# Suggests-Var:
# Short-Description: get $FAI directory from $FAI_CONFIG_SRC
### END SUBROUTINE INFO
if [ -z "$FAI_CONFIG_SRC" ]; then
sendmon "TASKERROR get_fai_dir 21"
echo "ERROR: No URL defined for the config space." >&2
echo "ERROR: Set \$FAI_CONFIG_SRC by using fai-chboot -u or use option -s when calling fai directly." >&2
exit 21
fi
echo "FAI_CONFIG_SRC is set to $FAI_CONFIG_SRC"
# extract method to get the config dir
# matched string: "cvs[+ssh]://user@host/path/to/cvsroot module[=tag]"
# ^^^
# "nfs://host/path/to/exported/config"
# ^^^
# the "major" protocol name is the one up to the first "+", if it exists
method=$(expr match "$FAI_CONFIG_SRC" '\([^+]*\).*://')
if [ -z "$method" ]; then
sendmon "TASKERROR get_fai_dir 22"
echo "Error in get-config-dir: scheme undefined." >&2
exit 24
echo
fi
[ -z "$FAI" -a $method != "file" ] && echo "WARNING: \$FAI is undefined. Let's see if it still works."
mkdir -m 0750 -p $FAI
# run get-config-dir-$method script if it exists
if command -v get-config-dir-$method &>/dev/null ; then
get-config-dir-$method
else
sendmon "TASKERROR get_fai_dir 22"
echo "Error: get-config-dir-"$method "not found" >&2
exit 22
fi
if [ $method = "file" ]; then
localpath=$(expr match "$FAI_CONFIG_SRC" '.*://\(/.*\)')
export FAI=$localpath
fi
ln -sf $FAI /var/run/fai/current_config
if [ ! -d $FAI/class ]; then
echo "WARNING: directory $FAI/class not found." >&2
sendmon "TASKERROR get_fai_dir 23"
exit 23
fi
exit 0