Skip to content

Commit

Permalink
Merge pull request #101 from ZryletTC/imgr
Browse files Browse the repository at this point in the history
Add imgr and merge iocmanager into one bash file
  • Loading branch information
ZryletTC authored Feb 16, 2022
2 parents 6c27ec3 + 0d5b403 commit 6f57ad5
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 16 deletions.
81 changes: 81 additions & 0 deletions scripts/imgr
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# Define usage here for faster return
usage()
{
cat << EOF
usage: imgr <IOCNAME> [--hutch HUTCH] <OPTION>
Control status of all IOCs running in a particular hutch from the command line.
Current hutch is used if not provided.
List of options:
imgr IOCNAME [--hutch HUTCH] --reboot soft
imgr IOCNAME [--hutch HUTCH] --reboot hard
imgr IOCNAME [--hutch HUTCH] --enable
imgr IOCNAME [--hutch HUTCH] --disable
imgr IOCNAME [--hutch HUTCH] --upgrade RELEASE_DIR
imgr IOCNAME [--hutch HUTCH] --move HOST
imgr IOCNAME [--hutch HUTCH] --move HOST:PORT
imgr [--hutch HUTCH] --list [--host HOST] [--enabled_only|--disabled_only]
EOF
}
if [ $# -lt 1 ]; then
echo 'Missing required arguments' >&2
usage
exit 1
elif [[ ($1 == "--help") || ($1 == "-h") ]]; then
usage
exit 0
fi

# Add engineering_tools to PATH for get_hutch_name
DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
PATH=$PATH:$DIR

# Search for hutch in args
for (( i=1; i<=$#; i++)); do
if [[ "${!i}" == "--hutch" ]]; then
ARGHUTCH_INDEX=$((i+1))
ARGHUTCH=${!ARGHUTCH_INDEX}
break
fi
done

# Hutch choice priority order:
# 1. --hutch arg
# 2. HUTCH environment variable
# 3. get_hutch_name
HUTCH=${ARGHUTCH:-$HUTCH}
HUTCH=${HUTCH:-$(get_hutch_name)}

# Exit if hutch is still unknown
# TODO: Replace with check for actual hutch names
if [[ "$HUTCH" == "unknown_hutch" ]]; then
echo "Unknown hutch, please use --hutch argument" >&2
exit 1
fi

# Setup environment
if [ -x /etc/pathinit ]; then
source /etc/pathinit
else
export PSPKG_ROOT=/cds/group/pcds/pkg_mgr
export PYPS_ROOT=/cds/group/pcds/pyps
export IOC_ROOT=/cds/group/pcds/epics/ioc
export CAMRECORD_ROOT=/cds/group/pcds/controls/camrecord
export IOC_DATA=/cds/data/iocData
export IOC_COMMON=/cds/data/iocCommon
fi
PSPKG_OS=$(${PSPKG_ROOT}/etc/pspkg_os.sh)
export PSPKG_OS
if [ "$PSPKG_OS" == rhel5 ]; then
echo "IocManager 2.0.0 and higher does not run on RHEL5!" >&2
exit 1
fi
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
export PSPKG_RELEASE=controls-0.1.9
source $PSPKG_ROOT/etc/set_env.sh

/reg/g/pcds/pyps/config/"${HUTCH,,}"/iocmanager/imgr.py "$@" --hutch "${HUTCH,,}"
52 changes: 36 additions & 16 deletions scripts/iocmanager
Original file line number Diff line number Diff line change
@@ -1,39 +1,59 @@
#!/bin/bash

# Define usage here for faster return
usage()
{
cat << EOF
usage: $0 [hutch]
usage: iocmanager [hutch]
Control status of all IOCs running in a particular hutch in an interactive GUI.
Current hutch is used if not provided.
EOF
}

if [[ ($1 == "--help") || ($1 == "-h") ]]; then
usage
exit 0
fi

ulimit -c unlimited

source /reg/g/pcds/setup/pathmunge.sh
ldpathmunge /usr/local/lib
# Check hutch
DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
PATH=$PATH:$DIR
HUTCH=${1:-$(get_hutch_name)}

DIRTMP=`dirname "${BASH_SOURCE[0]}"`
DIR="$( cd $DIRTMP && pwd -P )"
pathmunge $DIR
#PATH=$PATH:$DIR
# Exit if hutch is still unknown
# TODO: Replace with check for actual hutch names
if [[ "$HUTCH" == "unknown_hutch" ]]; then
echo "Unknown hutch, please specify e.g. 'iocmanager xrt'" >&2
exit 1
fi

if [ "$#" -ne 1 ]; then
HUTCH=`get_hutch_name`
# Setup environment
if [ -x /etc/pathinit ]; then
source /etc/pathinit
else
HUTCH=$1
export PSPKG_ROOT=/reg/g/pcds/pkg_mgr
export PYPS_ROOT=/reg/g/pcds/pyps
export IOC_ROOT=/reg/g/pcds/epics/ioc
export CAMRECORD_ROOT=/reg/g/pcds/controls/camrecord
export IOC_DATA=/reg/d/iocData
export IOC_COMMON=/reg/d/iocCommon
fi
PSPKG_OS=$(${PSPKG_ROOT}/etc/pspkg_os.sh)
export PSPKG_OS
if [ "$PSPKG_OS" == rhel5 ]; then
echo "IocManager 2.0.0 and higher does not run on RHEL5!"
exit 1
fi
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
export PSPKG_RELEASE=controls-0.1.9
source $PSPKG_ROOT/etc/set_env.sh
ulimit -c unlimited

/reg/g/pcds/pyps/config/${HUTCH}/iocmanager/IocManager --hutch $HUTCH > /dev/null &
/reg/g/pcds/pyps/config/"${HUTCH,,}"/iocmanager/IocManager.py --hutch "${HUTCH,,}" > /dev/null &

if [ `whoami` == "xppopr" ]; then
window_id=`xdotool search --sync --onlyvisible --name 'IocManager'`
# Do some window cleanup for xpp
if [ "$(whoami)" == "xppopr" ]; then
window_id=$(xdotool search --sync --onlyvisible --name 'IocManager')
if [ "xpp-control" == "$HOSTNAME" ]; then
wmctrl -v -i -r "$window_id" -e 0,3310,1100,530,1000
elif [ "xpp-daq" == "$HOSTNAME" ]; then
Expand Down

0 comments on commit 6f57ad5

Please sign in to comment.