Skip to content

Commit

Permalink
teach report to output conserver config
Browse files Browse the repository at this point in the history
manage-iocs report '' conserver

will generate results suitable to be #included by
conserver.cf

Also add update-iocs-cf to place the config in a known
  • Loading branch information
Michael Davidsaver committed May 9, 2011
1 parent 501fdde commit b5efa24
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 18 deletions.
11 changes: 4 additions & 7 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ Conserver is a process which connects to the telnet servers provided by all the

Edit /etc/conserver/conserver.cf to include the following line.

default procserv {type host; host localhost; }
default softioc { type host; host localhost;}
#include /etc/conserver/iocs.cf

See the conserver documentation for information on access control.

Expand Down Expand Up @@ -111,13 +112,9 @@ This creates/replaces the script /etc/init.d/softioc-example1

6) (optional) Configure Conserver

Add the following to /etc/conserver/conserver.cf
After creating /epics/iocs/example1/config run:

console example1 {
include procserv;
master myserver;
port 4051;
}
# update-iocs-cf

7) Manually starting the instance

Expand Down
1 change: 1 addition & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ install-indep: build-indep
install -m 644 epics-softioc $(basedir)/etc/default

install -m 755 manage-iocs $(basedir)/usr/bin
install -m 755 update-iocs-cf $(basedir)/usr/sbin

dh_install -i

Expand Down
1 change: 1 addition & 0 deletions debian/sysv-rc-softioc.dirs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
etc/init.d
etc/default
usr/bin
usr/sbin
usr/share/sysv-rc-softioc
3 changes: 3 additions & 0 deletions epics-softioc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

# base directory for IOC instance data (st.cmd, db, ...)
SOFTBASE=/epics/iocs

# location for generated conserver config
#IOCSCF=/etc/conserver/iocs.cf
8 changes: 6 additions & 2 deletions library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ iocinit() {
# $2 - IOC name (empty for all IOCs)
visit() {
[ -z "$1" ] && die "visitall: missing argument"
vcmd="$1"
vname="$2"
shift
shift

save_IFS="$IFS"
IFS=':'
Expand All @@ -39,8 +43,8 @@ visit() {
name="`basename "$ioc"`"
[ "$name" = '*' ] && continue

if [ -z "$2" -o "$name" = "$2" ]; then
$1 $ioc
if [ -z "$vname" ] || [ "$name" = "$vname" ]; then
$vcmd $ioc "$@"
fi
done
done
Expand Down
37 changes: 28 additions & 9 deletions manage-iocs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ usage() {
# $1 - iocdir
reportone() {
if [ -z "$HEADER" ]; then
printf "%-15s| %-15s| %-15s|%5s | %s\n" BASE IOC USER PORT EXEC
case "$2" in
conserver) # no header
;;
*)
printf "%-15s| %-15s| %-15s|%5s | %s\n" BASE IOC USER PORT EXEC
;;
esac
export HEADER=1
fi
local IOC="`basename $1`"
Expand All @@ -52,12 +58,24 @@ reportone() {
. "$1/config"
USER="${USER:-${IOC}}"
EXEC="${EXEC:-${INSTBASE}/st.cmd}"
if [ -n "$HOST" ]; then
[ "$HOST" != "$(hostname -s)" -a "$HOST" != "$(hostname -f)" ] && continue
else
HOST="<anywhere>"
fi
printf "%-15s| %-15s| %-15s|%5s | %s\n" $BASE $IOC $USER $PORT $EXEC
case "$2" in
conserver)
# skip IOC which don't specify a host
[ -n "$HOST" ] || continue
# identify if this is the host system
[ "$HOST" = "$(hostname -s)" -o "$HOST" = "$(hostname -f)" ] && HOST=localhost
echo "console $IOC {include softioc; master $HOST; port $PORT;}"
;;
all)
[ -n "$HOST" ] || HOST="<anywhere>"
printf "%-15s| %-15s| %-15s| %-15s|%5s | %s\n" $BASE $HOST $IOC $USER $PORT $EXEC
;;
*)
[ "$HOST" != "$(hostname -s)" -a "$HOST" != "$(hostname -f)" -a -n "$HOST" ] && continue
[ -n "$HOST" ] || HOST="<anywhere>"
printf "%-15s| %-15s| %-15s|%5s | %s\n" $BASE $IOC $USER $PORT $EXEC
;;
esac
}

installioc() {
Expand Down Expand Up @@ -128,7 +146,7 @@ shift

case "$cmd" in
report)
visit reportone "$1"
visit reportone "$@"
;;

list)
Expand Down Expand Up @@ -189,6 +207,7 @@ help)
usage
;;
*)
die "Unknown command $cmd"
die "Unknown command '$cmd'"
usage
;;
esac
31 changes: 31 additions & 0 deletions update-iocs-cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

die() {
echo "$1" >&2
exit 1
}

. /etc/default/epics-softioc

[ -d /etc/conserver ] || exit 0

tmp=$(tempfile) || die "Failed to create tempfile"

echo "## Generated by update-iocs-cf" > "$tmp"

manage-iocs report '' conserver >> "$tmp" || die "Failed to generate config"

if mv -f "$tmp" "${IOCSCF:=/etc/conserver/iocs.cf}"
then
chmod a+r "${IOCSCF:=/etc/conserver/iocs.cf}"
# poke daemon to reread config files
if type invoke-rc.d 2>&1 >/dev/null; then
invoke-rc.d conserver-server reload
else
/etc/init.d/conserver-server reload
fi
else
echo "Could not update /etc/conserver/iocs.cf"
fi

rm -f "$tmp"

0 comments on commit b5efa24

Please sign in to comment.