From 36249ce2c19f316d4d900bcf9f133c8f893dbd81 Mon Sep 17 00:00:00 2001
From: prjemian <prjemian@gmail.com>
Date: Thu, 29 Nov 2018 15:11:28 -0600
Subject: [PATCH] #16 indentation resolved - all spaces now

needs testing before closing this issue
---
 iocBoot/iocxxx/softioc/xxx.sh | 188 +++++++++++++++++-----------------
 1 file changed, 92 insertions(+), 96 deletions(-)

diff --git a/iocBoot/iocxxx/softioc/xxx.sh b/iocBoot/iocxxx/softioc/xxx.sh
index 127b93c..03d46c4 100755
--- a/iocBoot/iocxxx/softioc/xxx.sh
+++ b/iocBoot/iocxxx/softioc/xxx.sh
@@ -43,24 +43,23 @@ PS=ps
 SNAME=${BASH_SOURCE:-$0}
 SELECTION=$1
 
-if [ -z "$IOC_STARTUP_DIR" ]
-then
+if [ -z "$IOC_STARTUP_DIR" ] ; then
     # If no startup dir is specified, use the directory above the script's directory
     IOC_STARTUP_DIR=`dirname ${SNAME}`/..
-	IOC_CMD="../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} st.cmd.Linux"
+    IOC_CMD="../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} st.cmd.Linux"
 else
-	IOC_CMD="${IOC_STARTUP_DIR}/../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} ${IOC_STARTUP_DIR}/st.cmd.Linux"
+    IOC_CMD="${IOC_STARTUP_DIR}/../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} ${IOC_STARTUP_DIR}/st.cmd.Linux"
 fi
 #!${ECHO} ${IOC_STARTUP_DIR}
 
 #####################################################################
 
 screenpid() {
-        if [ -z ${SCREEN_PID} ] ; then
-	    ${ECHO}
-	else
-	    ${ECHO} " in a screen session (pid=${SCREEN_PID})"
-	fi
+    if [ -z ${SCREEN_PID} ] ; then
+        ${ECHO}
+    else
+        ${ECHO} " in a screen session (pid=${SCREEN_PID})"
+    fi
 }
 
 checkpid() {
@@ -71,61 +70,59 @@ checkpid() {
 
     if [ "${IOC_PID}" != "" ] ; then
         # Assume the IOC is down until proven otherwise
-	IOC_DOWN=1
+        IOC_DOWN=1
 
-	# At least one instance of the IOC binary is running; 
-	# Find the binary that is associated with this script/IOC
+        # At least one instance of the IOC binary is running; 
+        # Find the binary that is associated with this script/IOC
         for pid in ${IOC_PID}; do
-	    BIN_CWD=`${READLINK} /proc/${pid}/cwd`
-	    IOC_CWD=`${READLINK} -f ${IOC_STARTUP_DIR}`
-	    
-	    if [ "$BIN_CWD" == "$IOC_CWD" ] ; then
-		# The IOC is running; the binary with PID=$pid is the IOC that was run from $IOC_STARTUP_DIR
-		IOC_PID=${pid}
-		IOC_DOWN=0
-		
-		SCREEN_PID=""
-
-                if [ "${GET_SCREEN_PID}" == "YES" ]
-		then
-		    # Get the PID of the parent of the IOC (shell or screen)
-		    P_PID=`${PS} -p ${IOC_PID} -o ppid=`
-		    
-		    # Get the PID of the grandparent of the IOC (sshd, screen, or ???)
-		    GP_PID=`${PS} -p ${P_PID} -o ppid=`
-
-		    #!${ECHO} "P_PID=${P_PID}, GP_PID=${GP_PID}"
-
-		    # Get the screen PIDs
-		    S_PIDS=`${PGREP} screen`
-		
-		    for s_pid in ${S_PIDS}
-		    do
-		        #!${ECHO} ${s_pid}
-
-		        if [ "${s_pid}" == "${P_PID}" ] ; then
-			    SCREEN_PID=${s_pid}
-			    break
-	                fi
-		
-		        if [ "${s_pid}" == "${GP_PID}" ] ; then
-			    SCREEN_PID=${s_pid}
-			    break
-	                fi
-		
-		    done
-		fi
-		
-		break
-	    #else
-	    #    ${ECHO} "PATHS are different"
-	    #    ${ECHO} ${BIN_CWD}
-	    #    ${ECHO} ${IOC_CWD}
-	    fi
-	done
+            BIN_CWD=`${READLINK} /proc/${pid}/cwd`
+            IOC_CWD=`${READLINK} -f ${IOC_STARTUP_DIR}`
+            
+                if [ "$BIN_CWD" == "$IOC_CWD" ] ; then
+                    # The IOC is running; the binary with PID=$pid is the IOC that was run from $IOC_STARTUP_DIR
+                    IOC_PID=${pid}
+                    IOC_DOWN=0
+                    
+                    SCREEN_PID=""
+
+                    if [ "${GET_SCREEN_PID}" == "YES" ] ; then
+                        # Get the PID of the parent of the IOC (shell or screen)
+                        P_PID=`${PS} -p ${IOC_PID} -o ppid=`
+                        
+                        # Get the PID of the grandparent of the IOC (sshd, screen, or ???)
+                        GP_PID=`${PS} -p ${P_PID} -o ppid=`
+
+                        #!${ECHO} "P_PID=${P_PID}, GP_PID=${GP_PID}"
+
+                        # Get the screen PIDs
+                        S_PIDS=`${PGREP} screen`
+                    
+                        for s_pid in ${S_PIDS} ; do
+                            #!${ECHO} ${s_pid}
+
+                            if [ "${s_pid}" == "${P_PID}" ] ; then
+                                SCREEN_PID=${s_pid}
+                                break
+                            fi
+                    
+                            if [ "${s_pid}" == "${GP_PID}" ] ; then
+                                SCREEN_PID=${s_pid}
+                                break
+                            fi
+                    
+                        done
+                    fi
+                    
+                    break
+                    #else
+                    #    ${ECHO} "PATHS are different"
+                    #    ${ECHO} ${BIN_CWD}
+                    #    ${ECHO} ${IOC_CWD}
+                fi
+        done
     else
         # IOC is not running
-	IOC_DOWN=1
+        IOC_DOWN=1
     fi
 
     return ${IOC_DOWN}
@@ -134,19 +131,19 @@ checkpid() {
 start() {
     if checkpid; then
         ${ECHO} -n "${IOC_NAME} is already running (pid=${IOC_PID})"
-	screenpid
+        screenpid
     else
         ${ECHO} "Starting ${IOC_NAME}"
         cd ${IOC_STARTUP_DIR}
-	# Run xxx inside a screen session
-	${SCREEN} -dm -S ${IOC_NAME} -h 5000 ${IOC_CMD}
+        # Run xxx inside a screen session
+        ${SCREEN} -dm -S ${IOC_NAME} -h 5000 ${IOC_CMD}
     fi
 }
 
 stop() {
     if checkpid; then
         ${ECHO} "Stopping ${IOC_NAME} (pid=${IOC_PID})"
-	${KILL} ${IOC_PID}
+        ${KILL} ${IOC_PID}
     else
         ${ECHO} "${IOC_NAME} is not running"
     fi
@@ -169,10 +166,10 @@ status() {
 console() {
     if checkpid; then
         ${ECHO} "Connecting to ${IOC_NAME}'s screen session"
-	# The -r flag will only connect if no one is attached to the session
-	#!${SCREEN} -r ${IOC_NAME}
-	# The -x flag will connect even if someone is attached to the session
-	${SCREEN} -x ${IOC_NAME}
+        # The -r flag will only connect if no one is attached to the session
+        #!${SCREEN} -r ${IOC_NAME}
+        # The -x flag will connect even if someone is attached to the session
+        ${SCREEN} -x ${IOC_NAME}
     else
         ${ECHO} "${IOC_NAME} is not running"
     fi
@@ -181,21 +178,21 @@ console() {
 run() {
     if checkpid; then
         ${ECHO} -n "${IOC_NAME} is already running (pid=${IOC_PID})"
-	screenpid
+        screenpid
     else
         ${ECHO} "Starting ${IOC_NAME}"
         cd ${IOC_STARTUP_DIR}
-	# Run xxx outside of a screen session, which is helpful for debugging
-	${IOC_CMD}
+        # Run xxx outside of a screen session, which is helpful for debugging
+        ${IOC_CMD}
     fi
 }
 
 start_medm() {
-	${IOC_STARTUP_DIR}/../../start_MEDM_xxx
+    ${IOC_STARTUP_DIR}/../../start_MEDM_xxx
 }
 
 start_caqtdm() {
-	${IOC_STARTUP_DIR}/../../start_caQtDM_xxx
+    ${IOC_STARTUP_DIR}/../../start_caQtDM_xxx
 }
 
 usage() {
@@ -204,46 +201,45 @@ usage() {
 
 #####################################################################
 
-if [ ! -d ${IOC_STARTUP_DIR} ]
-then
+if [ ! -d ${IOC_STARTUP_DIR} ] ; then
     ${ECHO} "Error: ${IOC_STARTUP_DIR} doesn't exist."
     ${ECHO} "IOC_STARTUP_DIR in ${SNAME} needs to be corrected."
 else
     case ${SELECTION} in
         start)
-	    start
-	    ;;
+        start
+        ;;
 
         stop | kill)
-	    stop
-	    ;;
+        stop
+        ;;
 
         restart)
-	    restart
-	    ;;
+        restart
+        ;;
 
         status)
-	    status
-	    ;;
-	
+        status
+        ;;
+
         console)
             console
-	    ;;
+        ;;
 
         run)
             run
-	    ;;
-		
-		medm)
-			start_medm
-		;;
-		
-		caqtdm)
-			start_caqtdm
-		;;
+        ;;
+        
+        medm)
+            start_medm
+        ;;
+        
+        caqtdm)
+            start_caqtdm
+        ;;
 
         *)
-	    usage
-	    ;;
+        usage
+        ;;
     esac
 fi
-- 
GitLab