summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/50-install_dnbd3-server.inc
blob: 86deb5a8e56a0f8e8709ab5ffee81a9da3b8341d (plain) (blame)
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
install_dnbd3-server_service() {
	echo "# copying dnbd3-server service file..."
	cp -p "$BASEDIR/static_files/dnbd3/dnbd3-server.service" /etc/systemd/system/dnbd3-server.service || perror "failed."
	echo "# Linking dnbd3-server service file into (/etc/systemd/system/)multi-user.target.wants..."
	ln -s /etc/systemd/system/dnbd3-server.service /etc/systemd/system/multi-user.target.wants/dnbd3-server.service \
		|| perror "Could not link dnbd3-server service file into multiuser target!"
	echo "# copying dnbd3-master-proxy service file..."
	cp -p "$BASEDIR/static_files/dnbd3/dnbd3-master-proxy.service" /etc/systemd/system/dnbd3-master-proxy.service || perror "failed."
	echo "# Linking dnbd3-master-proxy service file into (/etc/systemd/system/)multi-user.target.wants..."
	ln -s /etc/systemd/system/dnbd3-master-proxy.service /etc/systemd/system/multi-user.target.wants/dnbd3-master-proxy.service \
		|| perror "Could not link dnbd3-master-proxy service file into multiuser target!"
}

install_dnbd3-server() {
	# $1: directory to install dnbd3-server to
	echo "# Installing dnbd3 server... "
	mkdir -p "$1" || perror "mkdir $1 failed"

	# Quick&dirty fix: dnbd3-server is downloaded via get_files_http, which dumps 
	# the files into $BASEDIR/static_files, not into $BASEDIR/static_files/dnbd3.
	mv "$BASEDIR/static_files/dnbd3-server" "$BASEDIR/static_files/dnbd3/" \
		|| perror "could not move dnbd3-server to static_files/dnbd3 (quickfix)."

	for i in dnbd3-server is-enabled; do
		cp -p "$BASEDIR/static_files/dnbd3/$i" "$1/$i" \
			|| perror "Could not copy $i to $1"
		chmod +x "$1/$i"
	done
	chown -R root:root "$1"

	mkdir -p /etc/dnbd3-server || perror "mkdir /etc/dnbd3-server failed"
	for i in rpc.acl server.conf; do
		cp -p "$BASEDIR/static_files/dnbd3/$i" "/etc/dnbd3-server/$i" \
			|| perror "Could not copy $i to /etc/dnbd3-server"
		chmod 644 "/etc/dnbd3-server/$i"
	done

	install_dnbd3-server_service "/etc/systemd/system/"
	echo "# dnbd3-server ok."
}