Last active
October 24, 2016 16:54
-
-
Save NaderCHASER/59635783ccd3148ed5a4c0daf7969625 to your computer and use it in GitHub Desktop.
LDM Product-queue Refresh Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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