mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			71 lines
		
	
	
	
		
			920 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
	
		
			920 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/sh
 | 
						|
 | 
						|
CONFFILE="/etc/yggdrasil.conf"
 | 
						|
 | 
						|
genconf() {
 | 
						|
	/usr/bin/yggdrasil -genconf > "$1"
 | 
						|
	return $?
 | 
						|
}
 | 
						|
 | 
						|
probetun() {
 | 
						|
	modprobe tun
 | 
						|
	return $?
 | 
						|
}
 | 
						|
 | 
						|
start() {
 | 
						|
	if [ ! -f "$CONFFILE" ]; then
 | 
						|
		printf 'Generating configuration file: '
 | 
						|
		if genconf "$CONFFILE"; then
 | 
						|
			echo "OK"
 | 
						|
		else
 | 
						|
			echo "FAIL"
 | 
						|
			return 1
 | 
						|
		fi
 | 
						|
	fi
 | 
						|
 | 
						|
	if [ ! -e /dev/net/tun ]; then
 | 
						|
		printf 'Inserting TUN module: '
 | 
						|
		if probetun; then
 | 
						|
			echo "OK"
 | 
						|
		else
 | 
						|
			echo "FAIL"
 | 
						|
			return 1
 | 
						|
		fi
 | 
						|
	fi
 | 
						|
 | 
						|
	printf 'Starting yggdrasil: '
 | 
						|
	if start-stop-daemon -S -b -x /usr/bin/yggdrasil \
 | 
						|
		-- --useconf < "$CONFFILE"; then
 | 
						|
		echo "OK"
 | 
						|
	else
 | 
						|
		echo "FAIL"
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
stop() {
 | 
						|
	printf "Stopping yggdrasil: "
 | 
						|
	if start-stop-daemon -K -q -x /usr/bin/yggdrasil; then
 | 
						|
		echo "OK"
 | 
						|
	else
 | 
						|
		echo "FAIL"
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
restart() {
 | 
						|
	stop
 | 
						|
	start
 | 
						|
}
 | 
						|
 | 
						|
reload() {
 | 
						|
	restart
 | 
						|
}
 | 
						|
 | 
						|
case "$1" in
 | 
						|
	start|stop|restart|reload)
 | 
						|
		"$1";;
 | 
						|
	*)
 | 
						|
		echo "Usage: $0 {start|stop|restart}"
 | 
						|
		exit 1
 | 
						|
esac
 | 
						|
 | 
						|
exit 0
 |