/usr/sbin/gapd is in gap-scscp 2.1.4+ds-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | #!/bin/sh
###########################################################################
scriptversion="2.1.4 (Debian 2.1.4+ds-1)"
###########################################################################
##
#W gapd The SCSCP package Alexander Konovalov
#W Steve Linton
##
## gapd [-h host] [-a] [-l] [-u] [-p port] [-t]
##
## The following options may be used to overwrite the default method to
## specify the hostname to run GAP SCSCP server, stated in scscp/config.g :
##
## 1) if '-h host' is specified, then the server will be started at 'host'.
## 'host' may be given as machine name with or without domain or even as
## 'localhost', though we have -l option for that purpose
##
## 2) if '-a' is specified, then the output of the call to 'hostname' will
## be used as the SCSCP server address
##
## 3) if '-l' is specified, then the server will be started at localhost
## and will not accept any incoming connections from the outside
##
## 4) if '-u' is specified, the server will be started in a "universal"
## mode and will accept all incoming connections
##
## The options 1-4 above are incompatible, so in case several of them will
## be given, only the option with the biggest number will be used
##
## If none of the options 1-4 above is stated, the hostname for the server
## will be taken from the scscp/config.g file
##
## Additionally, you may use the following options:
##
## 5) if '-p port' is specified, this will overwrite the default port for
## the SCSCP server given in scscp/config.g
##
## 6) if '-t' is specified then the output will be redirected to a
## temporary file, which name will be displayed on screen during
## startup. Otherwise, by default it will be redirected to /dev/null
##
###########################################################################
##
## modified on behalf of Debian by Jerome Benoit <calculus@rezozer.net>
##
###########################################################################
scriptname=${0##*/}
###########################################################################
##
## PART 0. DAEMON VARIABLES
##
###########################################################################
##
CONFDIR=/etc/scscp/gap
RUNDIR=/var/run/gapd
LOGDIR=/var/log/gapd
LOCKFILE=$RUNDIR/gapd.lock
PIDFILE=$RUNDIR/gapd.pid
LOGFILE=$LOGDIR/gapd.log
##
###########################################################################
###########################################################################
## USAGE
###########################################################################
##
## usage string formatted with help2man in mind
usage="\
Usage: $scriptname [-h HOST|-a|-l|-u] [-p PORT] [-t [MODE]] \
[--infolevel[-scscp|-master] LEVEL] [--help] [--version]
GAP Daemon - GAP SCSCP server daemon
Options:
-h HOST\tStart at host HOST: HOST may be given as machine name with or
\twithout domain or as 'localhost' (see option -l for that purpose).
-a \tSet server address to the one given by hostname(1).
-l \tStart at localhost: reject incoming any connection from the outside.
-u \tStart in \`universal' mode: accept all incoming connections.
-p PORT\tSet server port to PORT, default port set in \`${CONFDIR}/config.g'.
-t MODE\tRedirect the server session output according to the following MODEs:
\tMODE=no sink the output to \`/dev/null' (default behaviour);
\tMODE=log redirect the output to \`${LOGFILE}';
\tMODE=yes redirect the output to a temporary file, which name is displayed
\t(and printed to \`${LOGFILE}' for granted users);
\tthe implicit mode is MODE=yes for backward compatibility.
--infolevel-scscp LEVEL \tSet the GAP InfoLevel for SCSCP to LEVEL.
--infolevel-master LEVEL \tSet the GAP InfoLevel for MasterWorker to LEVEL.
--infolevel LEVEL \tIndiscriminately set the GAP InfoLevel_s to LEVEL.
--help \tPrint this help text and exit.
--version \tOutput version information and exit.
"
##
###########################################################################
###########################################################################
##
## PART 1. MODIFY PATHS IF NEEDED
##
###########################################################################
##
## Define the local call of GAP and call options, if necessary, for
## example, memory usage, start with the workspace etc. The path may be
## relative (to start from this directory) or absolute.
##
CGAP=/usr/bin/gap
GAP="$CGAP -b -r"
##
###########################################################################
##
## Define the configuration file for the SCSCP server. Note that since GAP
## reads the configuration file immediately before starting SCSCP server,
## you may redefine in it all variables that were set to their default
## values in scscp/config.g and scscp/configpar.g files (explicitly or
## reading your appropriately modified private copies of that files).
## The path may be relative (to start from this directory) or absolute.
##
SCSCP_CONFIG=${CONFDIR}/server.g
##
##
###########################################################################
###########################################################################
##
## PART 2. YOU NEED NOT TO MODIFY ANYTHING BELOW
##
###########################################################################
##
## Parse the arguments.
##
autohost="no"
localhost="no"
unimode="no"
use_temp_file="no"
host=";"
port=";"
infolevel_scscp=0
infolevel_master=0
option="yes"
while [ $option = "yes" ]; do
option="no"
case $1 in
-a) shift; option="yes"; autohost="yes";;
-h) shift; option="yes"; host=":=\""$1"\";"; shift;;
-l) shift; option="yes"; localhost="yes";;
-u) shift; option="yes"; unimode="yes";;
-p) shift; option="yes"; port=":="$1";"; shift;;
-t) shift; option="yes";
if [ 0 -lt $# ]; then
case "$1" in
-*) ;;
*)
case "$1" in
l|lo|log) use_temp_file="log" ;;
n|no) use_temp_file="no" ;;
y|ye|yes|*) use_temp_file="yes" ;;
esac
shift
;;
esac
else
use_temp_file="yes"
fi
;;
--infolevel-scscp) shift; option="yes"; infolevel_scscp=$1; shift;;
--infolevel-master) shift; option="yes"; infolevel_master=$1; shift;;
--infolevel) shift; option="yes";
infolevel_scscp=$1; shift; infolevel_master=$infolevel_scscp;;
--help) echo "$usage"; exit $?;;
--version) echo "$scriptname $scriptversion"; exit $?;;
esac
done
if [ -n ${TMPDIR} -a ! -w ${TMPDIR} ]; then
unset TMPDIR
fi
case "$use_temp_file" in
log)
OUTFILE=${LOGFILE}
;;
yes)
OUTFILE=$(mktemp --quiet --tmpdir gapd-XXXXXXXXXXX.log)
if [ -w ${LOGFILE} ]; then
cat >> ${LOGFILE} <<- EOM
#############################################################
#D log: ${OUTFILE}
EOM
fi
echo "Starting SCSCP server with output to ${OUTFILE}"
;;
*)
OUTFILE="/dev/null"
;;
esac
if [ $autohost = "yes" ]; then
host=":=Hostname();"
fi;
if [ $localhost = "yes" ]; then
host=":=false;"
fi;
if [ $unimode = "yes" ]; then
host=":=true;"
fi;
if [ $infolevel_scscp -lt 0 ]; then
infolevel_scscp=0
fi;
if [ $infolevel_master -lt 0 ]; then
infolevel_master=0
fi;
# Check whether ${OUTFILE} is writable
if [ -e ${OUTFILE} ]; then
if [ ! -w ${OUTFILE} ]; then
echo "the GAP daemon gapd can not write to the file ${OUTFILE}" 1>&2
exit 2
fi
else
OUTFOLDER=$(dirname ${OUTFILE})
if [ ! -w ${OUTFOLDER} ]; then
echo "the GAP daemon gapd can not write into the folder ${OUTFILE}" 1>&2
exit 2
fi
fi
# Check whether the GAP system is available
if [ ! -x $CGAP ]; then
echo "the GAP command-line interface $CGAP can not be executed" 1>&2
exit 2
fi
# Check whether the server configuration file is readable
if [ ! -r "${SCSCP_CONFIG}" ]; then
echo "the GAP SCSCP server configuration file ${SCSCP_CONFIG} can not be read" 1>&2
exit 2
fi
# Check whether the GAP daemon gapd is already launching
if [ -f ${LOCKFILE} ]; then
echo "the GAP daemon gapd may already launch as ${LOCKFILE} exists" 1>&2
exit 1
fi
touch ${LOCKFILE}
# Check whether the GAP SCSCP server is already running
if [ -f ${PIDFILE} ]; then
echo "the GAP SCSCP server may already run as ${PIDFILE} exists" 1>&2
rm -f ${LOCKFILE}
exit 1
fi
cat >> ${OUTFILE} <<- EOM
#############################################################
#D script: ${0} (${scriptversion})
#D date: $(date -u +%Y%m%dT%H%M%S.%NZ)
#D host: $(hostname)
#D user: $(id -un)
#D infolevel: SCSCP: ${infolevel_scscp}
#D infolevel: MasterWorker: ${infolevel_master}
#D TMPDIR: ${TMPDIR}
EOM
exec $GAP -q >> ${OUTFILE} 2>&1 <<-EOGS &
GAPDPrePare:=function()
local PIDFILE;
Print("#I GAPD: preparing\c");
PIDFILE:=OutputTextFile("${PIDFILE}",false);
if PIDFILE <> fail then
PrintTo(PIDFILE,GETPID(),"\n");
CloseStream(PIDFILE);
RemoveFile("${LOCKFILE}");
Print(".\n\c");
return true;
fi;
RemoveFile("${LOCKFILE}");
return fail;
end;;
GAPDPostPare:=function()
Print("#I GAPD: postparing\c");
RemoveFile("${PIDFILE}");
Print(".\n\c");
end;;
InstallAtExit(GAPDPostPare);
if GAPDPrePare() = fail then
QUIT_GAP();
fi;
LoadPackage("scscp");;
SetInfoLevel(InfoSCSCP,${infolevel_scscp});
SetInfoLevel(InfoMasterWorker,${infolevel_master});
SCSCPserverAddress${host};
SCSCPserverPort${port};
Read("${SCSCP_CONFIG}");
if SCSCPserverStatus=fail then
QUIT_GAP();
fi;
EOGS
###########################################################################
##
#E
##
|