summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrnmst/Franco Masotti2016-10-13 15:38:56 +0200
committerfrnmst/Franco Masotti2016-10-13 15:38:56 +0200
commitb4e10c9fee25fd6ac9c0bd8245124fa8b0437046 (patch)
tree019f9083b4c4d2ca1a0b536c307ae3661673be92
parentea897a92e2fd44cb0d5aa356c4ccc08093985bec (diff)
downloadaur-b4e10c9fee25fd6ac9c0bd8245124fa8b0437046.tar.gz
Updated to new installer version.
-rw-r--r--.INSTALL17
-rw-r--r--.SRCINFO2
-rw-r--r--PKGBUILD4
-rw-r--r--install_r_deps.R2
-rwxr-xr-xinstall_web_iface_deps.pl13
-rwxr-xr-xremove_web_iface_deps.pl3
-rwxr-xr-xrun.sh90
-rw-r--r--swish-cplint.conf25
-rw-r--r--swish-cplint.service34
9 files changed, 163 insertions, 27 deletions
diff --git a/.INSTALL b/.INSTALL
index c6f73b8f80d2..ebe4b16f5635 100644
--- a/.INSTALL
+++ b/.INSTALL
@@ -1,19 +1,28 @@
startdir=
post_install() {
+ # Add user and group.
+ getent group swish &>/dev/null || groupadd -r swish >/dev/null
+ getent passwd swish &>/dev/null || useradd -m -d /home/swish \
+-r -g swish swish >/dev/null
+
+ # Copy install script.
+ install -D -m744 ${startdir}/install_web_iface_deps.pl /home/swish/install_web_iface_deps.pl
+ chown swish:swish /home/swish/install_web_iface_deps.pl
+
echo ""
echo ""
- ${startdir}/install_web_iface_deps.pl
+ echo "You can start and enable \
+swish-cplint.service to run the server."
echo ""
echo ""
- echo "You can now start and enable \
-swish-cplint.service to run the server."
}
+# Trivial remove.
pre_remove() {
echo ""
echo ""
- ${startdir}/remove_web_iface_deps.pl
+ rm -rf /home/swish/lib
echo ""
echo ""
}
diff --git a/.SRCINFO b/.SRCINFO
index 924164091d91..a016980ca63c 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = swish-cplint
pkgdesc = SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite
pkgver = r8.13b29c6
- pkgrel = 3
+ pkgrel = 4
url = https://github.com/friguzzi/swish
install = .INSTALL
arch = x86_64
diff --git a/PKGBUILD b/PKGBUILD
index e13bb0a5211b..738bc96a632f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,8 @@
# Maintainer: Franco Masotti <franco dot masotti at student dot unife dot it>
+# Contributor: Franco Masotti <franco dot masotti at student dot unife dot it>
pkgname=swish-cplint
pkgver=r8.13b29c6
-pkgrel=3
+pkgrel=4
pkgdesc="SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite"
arch=('x86_64')
url="https://github.com/friguzzi/swish"
@@ -47,5 +48,6 @@ package() {
cp -r swish/* ${pkgdir}/usr/share/${pkgname}
install -D -m644 swish/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install -D -m644 ${startdir}/${pkgname}.service "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
+ install -D -m644 ${startdir}/${pkgname}.conf "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
ln -s /usr/share/${pkgname}/run.sh ${pkgdir}/usr/bin/${pkgname}
}
diff --git a/install_r_deps.R b/install_r_deps.R
new file mode 100644
index 000000000000..0f00d9385513
--- /dev/null
+++ b/install_r_deps.R
@@ -0,0 +1,2 @@
+install.packages(c("ggplot2"), repos="http://cran.us.r-project.org", dependencies=TRUE)
+install.packages("Rserve",,"http://rforge.net/",type="source")
diff --git a/install_web_iface_deps.pl b/install_web_iface_deps.pl
index 739c19b0bd67..076c0b96e33f 100755
--- a/install_web_iface_deps.pl
+++ b/install_web_iface_deps.pl
@@ -23,15 +23,16 @@
*
*/
+/* Package directory will be the default one */
:- initialization main.
-/* Solve problem with the matrix package. */
install:-
- pack_install(aleph, [interactive(false)]),
- pack_install(auc, [interactive(false)]),
- pack_install(real, [interactive(false)]),
- pack_install(matrix, [interactive(false)]),
- pack_install(cplint, [interactive(false)]).
+ pack_install(aleph, [url('https://github.com/friguzzi/aleph.git'),interactive(false)]),
+ pack_install(auc, [url('https://github.com/friguzzi/auc.git'),interactive(false)]),
+ pack_install(real, [url('http://stoics.org.uk/~nicos/sware/packs/real/real-2.0.tgz'),interactive(false)]),
+ pack_install(matrix, [url('https://github.com/friguzzi/matrix.git'),interactive(false)]),
+ pack_install(cplint, [url('https://github.com/friguzzi/cplint.git'),interactive(false)]),
+ pack_install('rserve_client', [url('https://github.com/JanWielemaker/rserve_client.git'),interactive(false)]).
main:-
catch(install, E, (print_message(error, E), fail)),
diff --git a/remove_web_iface_deps.pl b/remove_web_iface_deps.pl
index e3ee6c95e5cb..a63156c31154 100755
--- a/remove_web_iface_deps.pl
+++ b/remove_web_iface_deps.pl
@@ -30,7 +30,8 @@ remove:-
pack_remove(auc),
pack_remove(real),
pack_remove(matrix),
- pack_remove(cplint).
+ pack_remove(cplint),
+ pack_remove('rserve_client').
main:-
catch(remove, E, (print_message(error, E), fail)),
diff --git a/run.sh b/run.sh
index 385f5e2caddb..703c075d1533 100755
--- a/run.sh
+++ b/run.sh
@@ -24,16 +24,67 @@
# This is the file called from the /usr/bin/swish-cplint symlink
-# Since it's a dameon, it should be able to :
-# start
-# stop
-# (restart)
-
pid_file="/run/swish-cplint.pid"
+installed_file="/home/swish/installed"
+deps_installer="/home/swish/install_web_iface_deps.pl"
+user="swish"
+group="swish"
+
+help()
+{
+ cat<<-EOF
+swish-cplint [OPTION]
+SWI-Prolog for SHaring: a SWI-Prolog web IDE integrated with the cplint suite
+
+The first time swish-cplint is executed, all SWI Prolog dependencies will be
+installed.
+
+Only a single option is permitted.
+ -h print this help
+ -k kill swish-cplint
+ -s start swish-cplint
+
+Exit status:
+ 0 if OK,
+ 1 some error occurred.
-if [ "$UID" -eq 0 ]; then
+Full documentation at: <https://github.com/friguzzi/swish>
+and at: <https://github.com/friguzzi/cplint>
+EOF
+}
+
+kill()
+{
+ # 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 SIGTERM $pid
+ fi
+ fi
+}
+
+initialize()
+{
+ if [ -f "$installed_file" ]; then
+ :
+ else
+ printf "This may take a while.\n"
+ $deps_installer
+ if [ $? -eq 0 ]; then
+ echo "true" > "$installed_file"
+ else
+ printf "Install web dependencies error\n"
+ exit 1
+ fi
+ fi
+}
+
+start()
+{
{
- (exec swipl --quiet -f /usr/share/swish-cplint/run.pl) &
+ ( initialize && exec swipl --quiet -f /usr/share/swish-cplint/run.pl ) &
pid="$!"
} 1>/dev/null 2>/dev/null
@@ -45,7 +96,24 @@ if [ "$UID" -eq 0 ]; then
exit 1
fi
-else
- printf "User must be root\n"
- exit 1
-fi
+}
+
+main()
+{
+ if [ "$(id -un)" == "$user" ] && [ "$(id -gn)" == "$group" ]; then
+ :
+ else
+ printf "User and group must be swish\n"
+ exit 1
+ fi
+
+ getopts ":is" opt "$@"
+ case "$opt" in
+ h) help ;;
+ k) kill ;;
+ s) start ;;
+ ?) help ;;
+ esac
+}
+
+main "$@"
diff --git a/swish-cplint.conf b/swish-cplint.conf
new file mode 100644
index 000000000000..19f97697c36a
--- /dev/null
+++ b/swish-cplint.conf
@@ -0,0 +1,25 @@
+#
+# swish-cplint.conf
+#
+# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
+#
+# This file is part of cplint-installer.
+#
+# cplint-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,
+# 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/>.
+#
+#
+
+# To be placed in /usr/lib/tmpfiles.d/swish-cplint.conf
+
+f /run/swish-cplint.pid 0755 swish swish -
diff --git a/swish-cplint.service b/swish-cplint.service
index a77d153a2294..b58389668efc 100644
--- a/swish-cplint.service
+++ b/swish-cplint.service
@@ -1,13 +1,41 @@
+#
+# swish-cplint.service
+#
+# Copyright (C) 2016 frnmst (Franco Masotti) <franco.masotti@student.unife.it>
+#
+# This file is part of cplint-installer.
+#
+# cplint-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,
+# 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/>.
+#
+#
+
+# To be placed in /usr/lib/systemd/system/swish-cplint.service
+
[Unit]
Description=Cplint on SWISH
Documentation=http://github.com/friguzzi/cplint https://github.com/friguzzi/swish
[Service]
-ExecStart=/usr/bin/swish-cplint
+# Run ExecStartPre with root permissions.
+PermissionsStartOnly=true
+ExecStartPre=/usr/bin/systemd-tmpfiles --create swish-cplint.conf
+ExecStart=/usr/bin/swish-cplint -s
+ExecStop=/usr/bin/swish-cplint -k
Type=forking
PIDFile=/run/swish-cplint.pid
-User=root
-Group=root
+User=swish
+Group=swish
[Install]
WantedBy=default.target