Skip to content

Instantly share code, notes, and snippets.

@NaderCHASER
Last active October 24, 2016 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NaderCHASER/59635783ccd3148ed5a4c0daf7969625 to your computer and use it in GitHub Desktop.
Save NaderCHASER/59635783ccd3148ed5a4c0daf7969625 to your computer and use it in GitHub Desktop.
LDM Product-queue Refresh Script
[Unit]
Description=Unidata Local Data Manager
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStartPre=/home/ldm/scripts/pqrefresh.sh
ExecStartPre=/home/ldm/bin/ldmadmin mkqueue
ExecStart=/home/ldm/bin/ldmadmin start
ExecStop=/home/ldm/bin/ldmadmin stop
PIDFile=/home/ldm/ldmd.pid
Restart=on-failure
SuccessExitStatus=1
User=ldm
[Install]
WantedBy=multi-user.target
#!/bin/sh
export PATH=/bin:/usr/bin
LDMHOME=/home/ldm
LDMBIN=$LDMHOME/bin
LDMADMIN=$LDMBIN/ldmadmin
PQCHECK=$LDMBIN/pqcheck
PQCAT=$LDMBIN/pqcat
PQ=/dev/shm/ldm.pq
echo 'Inspecting LDM product-queue...'
if [ -x $LDMADMIN ] ; then
if $LDMADMIN isrunning; then
echo "LDM system is currently running. Aborting."
else
if [ ! -f $PQ ] ; then
echo "Product-queue doesn't exist. Creating..."
if ! $LDMADMIN mkqueue; then
echo "Aborting..."
exit 1
fi
else
echo "Product-queue exists. Checking..."
#
# Test the product-queue for corruption.
#
if ! $PQCHECK -l /dev/null -q $PQ; then
case $? in
0) echo "The product-queue is okay."
exit 0
;;
1) echo "System error checking product-queue. Aborting..."
exit 1
;;
2) echo "Adding writer-counter to product-queue..."
if ! $PQCHECK -F -q $PQ; then
echo "Aborting..."
exit 1
fi
;;
3) echo "Product-queue was incorrectly closed. " \
"Checking..."
if $PQCAT -s -l /dev/null; then
echo "Product-queue appears OK. "
echo "Clearing writer-counter..."
if ! $PQCHECK -F -q $PQ; then
echo "Couldn't clear counter. Aborting..."
exit 1
fi
else
echo "Product-queue appears corrupt. Deleting."
rm $PQ
if ! "$LDMADMIN mkqueue -f"; then
echo "Couldn't make new product-queue. Aborting..."
exit 1
fi
fi
;;
4) echo "Product-queue is corrupt. Deleting."
rm $PQ
if ! "$LDMADMIN mkqueue -f"; then
echo "Couldn't make new product-queue. Aborting..."
exit 1
fi
;;
esac
fi
fi
$LDMADMIN clean
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment