summarylogtreecommitdiffstats
path: root/run.sh
diff options
context:
space:
mode:
authorfrnmst/Franco Masotti2016-11-15 17:20:54 +0100
committerfrnmst/Franco Masotti2016-11-15 17:20:54 +0100
commit486cd1011db67dfe820646bf9b75b877eb9b2022 (patch)
tree2c882dc87075192f49f4c3a89d1eadd7be7c656f /run.sh
parentf54ef2a5aa63fd36026f5598fc46fbc23cbdd6b3 (diff)
downloadaur-486cd1011db67dfe820646bf9b75b877eb9b2022.tar.gz
Added install option. Lots of fixes.
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh79
1 files changed, 33 insertions, 46 deletions
diff --git a/run.sh b/run.sh
index 79f3ffe582f3..fcc09cf13d13 100755
--- a/run.sh
+++ b/run.sh
@@ -5,20 +5,20 @@
#
# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
#
-# This file is part of cplint-installer.
+# This file is part of swish-installer.
#
-# cplint-installer is free software: you can redistribute it and/or modify
+# swish-installer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
-# cplint-installer is distributed in the hope that it will be useful,
+# swish-installer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with cplint-installer. If not, see <http://www.gnu.org/licenses/>.
+# along with swish-installer. If not, see <http://www.gnu.org/licenses/>.
#
#
@@ -34,13 +34,11 @@ help()
rsd [OPTION]
Docker spec for running Rserve in a sandbox
-The first time rserve-sandbox-docker is executed,
-a docker image will be downloaded. This operation might take a while.
-
Only a single option is permitted.
-h print this help
- -k kill rsd
- -s start rsd
+ -i install dependencies
+ -k kill rserve-sandbox-docker
+ -s start rserve-sandbox-docker
Exit status:
0 if OK,
@@ -50,28 +48,26 @@ Full documentation at: <https://github.com/frnmst/rserve-sandbox>
EOF
}
-# Kill ideas (deprecated).
- # This addresses only docker containers available to rsd:rsd.
- # Simple solution.
-
-
- # More complex solution requires deleting all containers (running and
- # stopped) matching rserve-sandbox-docker
- # If this is not done, the hard disk might get full quickly.
- # Something like the following might be useful.
- #
- # containers="$(docker ps -a -f status=exited \
-#--format \"{{.ID}}\\t{{.Image}}\" | grep rserve-sandbox-docker)"
- # echo "$containers" | awk '{print $1} | xargs docker rm
-
- # Or simply add rm option to the makefile
-
-initialize()
+init()
{
# Check if rserve image does not exist.
if [ -z "$(docker images -q "$docker_image_name")" ]; then
- printf "This might take a while\n"
+ printf "%s\n" "This might take a while"
+ pushd "$pkg_dir"
make image
+ else
+ 1>&2 printf "%s\n" "Docker image already installed"
+ exit 1
+ fi
+}
+
+installed()
+{
+ if [ -z "$(docker images -q "$docker_image_name")" ]; then
+ 1>&2 printf "%s\n" "You need to run \
+'sudo -u rsd rserve-sandbox-docker -i' \
+first"
+ exit 1
fi
}
@@ -92,13 +88,15 @@ startd()
{
local pid=""
+ # The following means installed && { ... }
+ installed
{
(
cd "$pkg_dir"
- initialize && make run
+ make run
) &
pid="$!"
- } 1>/dev/null 2>/dev/null
+ }
write_pid_file "$pid"
}
@@ -151,26 +149,15 @@ write_pid_file()
fi
}
-killd()
-{
- # kill action only if process exists.
- if [ -f "$pid_file" ]; then
- pid=$(cat "$pid_file")
- ps -q $pid > /dev/null
- if [ $? -eq 0 ]; then
- kill -s TERM $pid
- fi
- fi
-}
-
option_parser()
{
- getopts ":hks" opt "$@"
+ getopts ":hiks" opt "$@"
case "$opt" in
- h) help ;;
- k) killd ;;
- s) startd ;;
- ?) help; return 1 ;;
+ h ) help ;;
+ i ) init ;;
+ k ) killd ;;
+ s ) startd ;;
+ ? ) help; return 1 ;;
esac
}