cerebrate / wabash

A utility to hold a WSL session-set open continuously. Works in conjunction with wabashd.
Microsoft Public License
81 stars 4 forks source link

Feature Request: allow arbitrary commands when starting up #9

Open heldchen opened 7 years ago

heldchen commented 7 years ago

first of all: thanks for the tool, it's already very useful.

as an improvement, I suggest to allow executing arbitrary command when wabash starts the initial bash session. in my case, I need a sudo mount -a to mount some shares defined in /etc/fstab

cerebrate commented 7 years ago

Hm. I'd prefer not to add extra complexity for any features that are already covered on the Linux side -- is there any reason you couldn't add this as a service configuration in /etc/init (similar to /etc/init/binfmt-support.conf, say), and then start it using the existing service support in wabash? Since wabashd is acting as fake-init to start these services, this seems to be the most Linuxy way of getting what you want.

heldchen commented 7 years ago

I understand your reasoning, but I hoped to not having to specify artificial services just to run simple one-off commands :)

the mount --all command for example would have to become /etc/init.d/mount-fstab to be usable in wabashd:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mount-fstab
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Mount fstab mounts
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mount-fstab
DESC="mount fstab mounts"

if [ "$(uname)" != Linux ]; then
  exit 0
fi

. /lib/lsb/init-functions
[ -r /etc/default/rcS ] && . /etc/default/rcS

set -e
CODE=0

case "$1" in
  start|restart|reload)
    if init_is_upstart; then
      exit 1
    fi
    log_daemon_msg "Enabling $DESC" "$NAME"
    mount --all || CODE=$?
    log_end_msg $CODE
    exit $CODE
    ;;

  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|restart|reload}" >&2
    exit 1
    ;;
esac

exit 0

would you consider to instead adding an option to have wabash execute /etc/rc.local at the end of faking init, so that simple commands could be run?