Skip to content

Commit

Permalink
mxstartup: Import files form source repository
Browse files Browse the repository at this point in the history
Import files from b51f29e5 ("Merge pull request #10 from
mariux64/fix-su-option") of github.molgen.mpg.de:mariux64/mxstartup.git
into repository.

It is just cumbersome to have these n a seperate repository with
releases and bee installation.

The mxstartup bee package should be deinstalled if this is merged.
  • Loading branch information
donald committed Jul 4, 2023
1 parent 2cd5645 commit 2e40367
Show file tree
Hide file tree
Showing 6 changed files with 693 additions and 0 deletions.
5 changes: 5 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ install_data misc_etc_files/modprobe.d/disable-i915.conf "$DESTDIR$sysconfdir/m
install_data misc_systemd_units/i915.service "$DESTDIR$systemdunitdir/i915.service"
install_data misc_systemd_units/mxstartup.service.d/fix-tmp.conf \
"$DESTDIR$systemdunitdir/mxstartup.service.d/fix-tmp.conf"
install_exec mxstartup/mxservicectl "$DESTDIR$usr_sbindir/mxservicectl"
install_exec mxstartup/mxstartup2mxconfig "$DESTDIR$usr_sbindir/mxstartup2mxconfig"
install_exec mxstartup/mxstartupctl "$DESTDIR$usr_sbindir/mxstartupctl"
install_exec mxstartup/mxvipctl "$DESTDIR$usr_sbindir/mxvipctl"
install_data mxstartup/mxstartup.service "$DESTDIR$systemdunitdir/mxstartup.service"

postinstall
exit
150 changes: 150 additions & 0 deletions mxstartup/mxservicectl
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/bash

CMD_IP="/sbin/ip"
CMD_MXS2MXSRV="/usr/sbin/mxstartup2mxconfig"

RUNDIR="/run/mariux"

# expands *-pattern in pathnames to null if no matching files are found..
shopt -s nullglob

# exit on any error
set -e

function mxsrv_start_one() {
local cfg=$1
local -i i mip mfwd

echo "starting ${cfg} .."

. ${cfg}

test "$MX_SRV_USER" = "-" && MX_SRV_USER="root"

case "${MX_SRV_SCRIPT}" in
*.service)
systemctl start "${MX_SRV_SCRIPT}" || true
;;
*)
su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" &
;;
esac

mv ${cfg}{,.r}

unset -v MX_SRV_USER MX_SRV_SCRIPT
}

function mxsrv_stop_one() {
local cfg=$1
local -i i mip mfwd

echo "stopping ${cfg} .."

. ${cfg}

test "$MX_SRV_USER" = "-" && MX_SRV_USER="root"

case "${MX_SRV_SCRIPT}" in
*.service)
systemctl stop "${MX_SRV_SCRIPT}" || true
;;
*)
su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" &
;;
esac

rm ${cfg}

unset -v MX_SRV_USER MX_SRV_SCRIPT
}

function mxsrv_start() {
local cfg
local pattern=$1

: ${pattern:=*}

for cfg in ${RUNDIR}/mxservice.${pattern}.cfg ; do
if [ -e ${cfg}.r ] ; then
echo >&2 "skipping $cfg: already running.."
continue
fi

if [ ! -r ${cfg} ] ; then
echo >&2 "skipping $cfg: can't read file"
continue
fi

if [ ! -O ${cfg} ] ; then
echo >&2 "skipping $cfg: possible hack attempt?"
continue
fi

mxsrv_start_one ${cfg}

done
}

function mxsrv_stop() {
local cfg
local pattern=$1

: ${pattern:=*}

for cfg in ${RUNDIR}/mxservice.${pattern}.cfg.r ; do
if [ ! -r ${cfg} ] ; then
echo >&2 "skipping $cfg: can't read file"
continue
fi

if [ ! -O ${cfg} ] ; then
echo >&2 "skipping $cfg: possible hack attempt?"
continue
fi

mxsrv_stop_one ${cfg}

done
}


function create_run_dir_if_not_exists() {
if [ ! -d ${RUNDIR} ] ; then
mkdir -m 0700 ${RUNDIR}
fi

if [ ! -O ${RUNDIR} ] ; then
echo >&2 "${RUNDIR}: wrong owner: possible hack attempt? exiting.."
exit 1
fi
}

function create_mxservice() {
${CMD_MXS2MXSRV} ${RUNDIR} >/dev/null
}


##############################################################################

create_run_dir_if_not_exists

case "${1}" in
start)
create_mxservice
mxsrv_start $2
;;
stop)
mxsrv_stop $2
;;
restart)
mxsrv_stop $2
create_mxservice
mxsrv_start $2
;;
*)
echo >&2 "$0 start|stop"
;;
esac


14 changes: 14 additions & 0 deletions mxstartup/mxstartup.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Mariux mxstartup classic
After=mxmount.service network.target
Requires=mxmount.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/mxstartupctl start
ExecStop=/usr/sbin/mxstartupctl stop
RemainAfterExit=yes
StandardOutput=syslog

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 2e40367

Please sign in to comment.