#!/bin/sh

### BEGIN INIT INFO
# Provides:          fll-lxqt-desktop
# Required-Start:    $local_fs $remote_fs fll-adduser
# Required-Stop:
# X-Start-Before:    fll-common-desktop
# Default-Start:     S
# Default-Stop:
# Short-Description: prepare live user for lxqt desktop
# Description:       The purpose of this script is to preseed the live users
#                    settings for the lxqt desktop.
### END INIT INFO

###
# F.U.L.L.S.T.O.R.Y init script
#
# Copyright: (C) 2007-2008 Kel Modderman <kel@otaku42.de>
# Copyright: (C) 2008-2016 Stefan Lippers-Hollmann <s.l-h@gmx.de>
# License:   GPLv2
#
# F.U.L.L.S.T.O.R.Y Project Homepage:
# https://github.com/fullstory
###

PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME="fll-lxqt-desktop"

###
# source distro-defaults, no-op unless in live mode
###
FLL_DISTRO_MODE="installed"

if [ -r /etc/default/distro ]; then
	. /etc/default/distro
fi

if [ "${FLL_DISTRO_MODE}" != "live" ]; then
	exit 0
fi

###
# source lsb functions
###
. /lib/lsb/init-functions

###
# source fll functions
###
. /lib/init/fll

###
# read in variables from our default conffile
###
if [ -r "/etc/default/${NAME}" ]; then
	. "/etc/default/${NAME}"
fi

###
# read in variables from /etc/default/fll-locales
###
if [ -r /etc/default/fll-locales ]; then
	. /etc/default/fll-locales
fi

###
# cheatcode handling
###
for param in $(cat /proc/cmdline); do
	case "${param}" in
		flldebug=*)
			if [ "${param#flldebug=}" = "${NAME#fll-}" ] || [ "${param#flldebug=}" = "all" ]; then
                    		fll_redirect
			fi
			;;
	esac
done

do_start()
{
	su "${FLL_LIVE_USER}" -c /usr/share/desktop-defaults-lxqt/preseed-user-home-lxqt
}

case "${1}" in
	start)
		log_daemon_msg "${NAME}"
		log_action_begin_msg " preparing ${FLL_LIVE_USER} for lxqt"
		do_start
		log_end_msg 0
		;;
	stop)
		;;
	restart|force-reload)
		echo "Error: argument '${1}' not supported" >&2
		exit 3
		;;
	status)
		log_success_msg "${0} is no dæmon."
		exit 0
		;;
	*)
		echo "Usage: ${NAME} {start|stop}" >&2
		exit 3
		;;
esac

:
