#!/bin/sh
#
# Univention Updater
#  add apache/UMC executable permissions
#
# SPDX-FileCopyrightText: 2010-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

action='restart'

die () {
	echo "${0##/*}: $*" >&2
	exit 1
}
opt="$(getopt -o 'h' --longoptions 'no-restart,help' -- "$@")" ||
	die 'Terminating...'
eval set -- "$opt"
while [ $# -ge 1 ]
do
	case "$1" in
	-h|--help)
		echo "${0##*/} [--help] [--no-restart]"
		exit 0
		;;
	--no-restart)
		action='start'
		shift
		;;
	--)
		shift
		break
		;;
	*)
		die 'Internal error!'
		;;
	esac
done

systemctl unmask --runtime univention-management-console-server.service
systemctl "$action" univention-management-console-server.service apache2.service

exit 0
