diff --git a/salt/common/tools/sbin/so-restart b/salt/common/tools/sbin/so-restart index bbcfe4c20..176283deb 100755 --- a/salt/common/tools/sbin/so-restart +++ b/salt/common/tools/sbin/so-restart @@ -19,18 +19,22 @@ . /usr/sbin/so-common -echo $banner -printf "Restarting $1...\n\nThis could take a while if another Salt job is running. \nRun this command with --force to stop all Salt jobs before proceeding.\n" -echo $banner +if [ $# -ge 1 ]; then -if [ "$2" = "--force" ] -then - printf "\nForce-stopping all Salt jobs before proceeding\n\n" - salt-call saltutil.kill_all_jobs + echo $banner + printf "Restarting $1...\n\nThis could take a while if another Salt job is running. \nRun this command with --force to stop all Salt jobs before proceeding.\n" + echo $banner + + if [ "$2" = "--force" ]; then + printf "\nForce-stopping all Salt jobs before proceeding\n\n" + salt-call saltutil.kill_all_jobs + fi + + case $1 in + "cortex") docker stop so-thehive-cortex so-thehive && docker rm so-thehive-cortex so-thehive && salt-call state.apply hive queue=True;; + "steno") docker stop so-steno && docker rm so-steno && salt-call state.apply pcap queue=True;; + *) docker stop so-$1 ; docker rm so-$1 ; salt-call state.apply $1 queue=True;; + esac +else + echo -e "\nPlease provide an argument by running like so-restart $component, or by using the component-specific script.\nEx. so-restart filebeat, or so-filebeat-restart\n" fi - -case $1 in - "cortex") docker stop so-thehive-cortex so-thehive && docker rm so-thehive-cortex so-thehive && salt-call state.apply hive queue=True;; - "steno") docker stop so-steno && docker rm so-steno && salt-call state.apply pcap queue=True;; - *) docker stop so-$1 ; docker rm so-$1 ; salt-call state.apply $1 queue=True;; -esac diff --git a/salt/common/tools/sbin/so-start b/salt/common/tools/sbin/so-start index 690950373..36517ee6a 100755 --- a/salt/common/tools/sbin/so-start +++ b/salt/common/tools/sbin/so-start @@ -19,18 +19,21 @@ . /usr/sbin/so-common -echo $banner -printf "Starting $1...\n\nThis could take a while if another Salt job is running. \nRun this command with --force to stop all Salt jobs before proceeding.\n" -echo $banner +if [ $# -ge 1 ]; then + echo $banner + printf "Starting $1...\n\nThis could take a while if another Salt job is running. \nRun this command with --force to stop all Salt jobs before proceeding.\n" + echo $banner -if [ "$2" = "--force" ] -then - printf "\nForce-stopping all Salt jobs before proceeding\n\n" - salt-call saltutil.kill_all_jobs + if [ "$2" = "--force" ]; then + printf "\nForce-stopping all Salt jobs before proceeding\n\n" + salt-call saltutil.kill_all_jobs + fi + + case $1 in + "all") salt-call state.highstate queue=True;; + "steno") if docker ps | grep -q so-$1; then printf "\n$1 is already running!\n\n"; else docker rm so-$1 >/dev/null 2>&1 ; salt-call state.apply pcap queue=True; fi ;; + *) if docker ps | grep -E -q '^so-$1$'; then printf "\n$1 is already running\n\n"; else docker rm so-$1 >/dev/null 2>&1 ; salt-call state.apply $1 queue=True; fi ;; + esac +else + echo -e "\nPlease provide an argument by running like so-start $component, or by using the component-specific script.\nEx. so-start filebeat, or so-filebeat-start\n" fi - -case $1 in - "all") salt-call state.highstate queue=True;; - "steno") if docker ps | grep -q so-$1; then printf "\n$1 is already running!\n\n"; else docker rm so-$1 >/dev/null 2>&1 ; salt-call state.apply pcap queue=True; fi ;; - *) if docker ps | grep -E -q '^so-$1$'; then printf "\n$1 is already running\n\n"; else docker rm so-$1 >/dev/null 2>&1 ; salt-call state.apply $1 queue=True; fi ;; -esac diff --git a/salt/common/tools/sbin/so-stop b/salt/common/tools/sbin/so-stop index 4a0dd944b..f0ce6b4d4 100755 --- a/salt/common/tools/sbin/so-stop +++ b/salt/common/tools/sbin/so-stop @@ -19,11 +19,15 @@ . /usr/sbin/so-common -echo $banner -printf "Stopping $1...\n" -echo $banner +if [ $# -ge 1 ]; then + echo $banner + printf "Stopping $1...\n" + echo $banner -case $1 in - *) docker stop so-$1 ; docker rm so-$1 ;; -esac + case $1 in + *) docker stop so-$1 ; docker rm so-$1 ;; + esac +else + echo -e "\nPlease provide an argument by running like so-stop $component, or by using the component-specific script.\nEx. so-stop filebeat, or so-filebeat-stop\n" +fi