librobotcontrol-sys 0.4.0

Rust port of librobotcontrol
Documentation
#!/bin/sh

# don't put anything before here or it will break debconf!

set -e	# exit on error
. /usr/share/debconf/confmodule # Source debconf library.

# enable services, but don't start yet
systemctl daemon-reload
systemctl enable robotcontrol
systemctl enable rc_battery_monitor

# in interactive mode, ask for configuration options
if [ ! "$DEBIAN_FRONTEND" = "noninteractive" ] ; then

	set +e

	# Fetching configuration from debconf
	db_get librobotcontrol/q_enable_dt
	ENABLE_DT=$RET
	db_get librobotcontrol/q_runonboot
	PROG=$RET

	# set something or nothing to run on boot. Default was 'none' which removes
	# any existing link. If 'existing' was selected then link is left alone
	 # make sure /etc/robotcontrol exists
	if [ ! -d "/etc/robotcontrol" ]; then
		echo "making /etc/robotcontrol"
		mkdir /etc/robotcontrol
	fi
	if [ "$PROG" = "rc_blink" ]; then
		echo "setting rc_blink to run on boot"
		ln -s -f /usr/bin/rc_blink /etc/robotcontrol/link_to_startup_program
	elif [ "$PROG" = "rc_balance" ]; then
		ln -s -f /usr/bin/rc_balance /etc/robotcontrol/link_to_startup_program
		echo "setting rc_balance to run on boot"
	elif [ "$PROG" = "none" ]; then
		echo "setting nothing to run on boot"
		rm -f /etc/robotcontrol/link_to_startup_program
	else
		echo "leaving current robot control startup program alone"
	fi


	# try to start services, but ignore errors as this may not work
	systemctl start rc_battery_monitor
	systemctl start robotcontrol

	# leave error checking off when setting up device tree too
	if [ "$ENABLE_DT" = "true" ]; then
		echo "Configuring Device Tree"
		configure_robotics_dt
	fi

	echo "**********************************************"
	echo "librobotcontrol package installation complete."
	if [ "$ENABLE_DT" = "true" ]; then
		echo "Please reboot now to load new device tree."
	fi
	echo "**********************************************"

	# put error checking back on in case debhelper wants it
	set -e

fi

#DEBHELPER#

exit 0