diff --git a/README.md b/README.md index 20f923b..c3fde93 100644 --- a/README.md +++ b/README.md @@ -37,29 +37,39 @@ Check that your user is part of `docker` group: sudo adduser docker +If needed, you need to logout and login again for the new group to +become active. ## manual install cd git clone https://git.grandou.net/gilles/runon -local install, in you `~/bin` (or wherever directory which is in your +local install, in your `~/local/bin` (or wherever directory which is in your PATH): - cd ~/bin - ln -s ~/tools/runon/runon + cd + ./install local - mkdir ~/.config/runon - cp /runon/runon.conf ~/.config/runon/ +or -system install, for all users, as `root`: + ./install local - mkdir /etc/runon - cp /run/runon /usr/local/bin/runon - cp /run/runon.conf /etc/runon/ +system install, for all users: -each user can have its own configuration in `~/.config/runon/runon.conf`. + cd + sudo ./install system +each user can have its own configuration in `~/.config/runon/runon.conf` +if needed. + +## uninstall + +simply pass `-u` to install command you have used, eg.: + + ./install local -u + ./install local -u + sudo ./install system -u ## some convenient links diff --git a/install b/install new file mode 100755 index 0000000..ed18fc3 --- /dev/null +++ b/install @@ -0,0 +1,88 @@ +#!/usr/bin/bash + +local_bin_dir=~/local/bin +local_config_dir=~/.config/runon +system_bin_dir=/etc/runon +system_config_dir=/usr/local/bin + +op=install +bin_dir=$local_bin_dir +config_dir=$local_config_dir + +function usage +{ + echo "$0 [local|system] [-u|--uninstall] []" + echo + echo " local install for local user, by default" + echo " system install for all users" + echo " dev install in dev mode (create links to source)" + echo " -u, --uninstall local or system uninstall" + echo " destination dir for binary" + echo + echo "default local paths:" + echo " binary: $local_bin_dir" + echo " config: $local_config_dir" + echo + echo "default system paths:" + echo " binary: $system_bin_dir" + echo " config: $system_config_dir" + echo +} + +function do_exec +{ + echo "$@" + "$@" +} + +while [ $# -gt 0 ]; do + case $1 in + local) + bin_dir=$local_bin_dir + config_dir=$local_config_dir + ;; + system) + bin_dir=$system_bin_dir + config_dir=$system_config_dir + ;; + dev) + bin_dir=$local_bin_dir + config_dir=$local_config_dir + op=installdev + ;; + -u) + op=uninstall + ;; + --uninstall) + op=uninstall + ;; + -h*) + usage + exit 0 + ;; + *) bin_dir=$1 + ;; + esac + shift +done + +set -e + +if [ "$op" = "install" ]; then + do_exec install -d $bin_dir + do_exec install -d $config_dir + #rm -f $bin_dir/runon + #rm -f $config_dir/runon + do_exec install runon $bin_dir + do_exec install runon.conf $config_dir +elif [ "$op" = "installdev" ]; then + do_exec install -d $bin_dir + do_exec install -d $config_dir + do_exec ln -s -f $(realpath runon) $bin_dir/ + do_exec ln -s -f $(realpath runon.conf) $config_dir/ +elif [ "$op" = "uninstall" ]; then + do_exec rm -f $bin_dir/runon + do_exec rm -f $config_dir/runon.conf + test -d $bin_dir && do_exec rmdir --parents --ignore-fail-on-non-empty $bin_dir 2> /dev/null + test -d $config_dir && do_exec rmdir --parents --ignore-fail-on-non-empty $config_dir 2> /dev/null +fi