add install script

This commit is contained in:
Gilles Grandou 2021-04-30 20:03:24 +02:00
parent 1c374d0f0b
commit 7e33632132
2 changed files with 108 additions and 10 deletions

View File

@ -37,29 +37,39 @@ Check that your user is part of `docker` group:
sudo adduser <user> docker sudo adduser <user> docker
If needed, you need to logout and login again for the new group to
become active.
## manual install ## manual install
cd <tools> cd <tools>
git clone https://git.grandou.net/gilles/runon 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): PATH):
cd ~/bin cd <runon>
ln -s ~/tools/runon/runon ./install local
mkdir ~/.config/runon or
cp <tools>/runon/runon.conf ~/.config/runon/
system install, for all users, as `root`: ./install local <your_bin_path>
mkdir /etc/runon system install, for all users:
cp <tools>/run/runon /usr/local/bin/runon
cp <tools>/run/runon.conf /etc/runon/
each user can have its own configuration in `~/.config/runon/runon.conf`. cd <runon>
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 <dir>
sudo ./install system -u
## some convenient links ## some convenient links

88
install Executable file
View File

@ -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] [<dest>]"
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 " <dest> 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