Skip to main content
typo
Source Link
chillin
  • 2.9k
  • 2
  • 21
  • 33

What you're left with is three little apps to put in your dock that, when launched, will start or stop the ftp service on your preferred network interface, or tell you what's up with ftp, respectively, and should not require any admin password. I only had time to test the first one, so if they don't work askas I hope they do, then you can comment out or delete my logic and use your launchctl method.

What you're left with is three little apps to put in your dock that, when launched, will start or stop the ftp service on your preferred network interface, or tell you what's up with ftp, respectively, and should not require any admin password. I only had time to test the first one, so if they don't work ask I hope they do, then you can comment out or delete my logic and use your launchctl method.

What you're left with is three little apps to put in your dock that, when launched, will start or stop the ftp service on your preferred network interface, or tell you what's up with ftp, respectively, and should not require any admin password. I only had time to test the first one, so if they don't work as I hope they do, then you can comment out or delete my logic and use your launchctl method.

Source Link
chillin
  • 2.9k
  • 2
  • 21
  • 33

Why use Automator when you can stay in bash?

I found a really cool little script called appify that will instantly turn other scripts into actual applications. You can try it a few times to observe its behavior. Since you already use bash, I am hoping that this answer as an alternative to exactly what you are asking for is acceptable.

The idea is to split your script into 3 distinct scripts:


1: start ftp service on preferred network interface only

 #!/bin/bash
 #start ftp service
 #sudo="/usr/bin/sudo"
 #launchctl="/bin/launchctl"
 say="/usr/bin/say"
 networksetup="/usr/sbin/networksetup"
 tail="/usr/bin/tail"
 head="/usr/bin/head"
 cut="/usr/bin/cut"
 curl="/usr/bin/curl"
 currentInterface=$(networksetup -listnetworkserviceorder |tail +2 |head -n1 |cut -c5-12)
 getExternaladdress=$(curl ipecho.net/plain)
 SiriSays="say -v Samantha"
 #sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist 
 #your command will start ftp on all network interfaces
 if [ "$currentInterface" = "Airport" ]; 
      then
           networksetup -setpassiveftp Airport on
      else
           networksetup --setpassiveftp Ethernet on
 fi
 $SiriSays "ftp service has been initiated for the"
 echo $currentInterface |$SiriSays; $SiriSays "interface"
 $SiriSays "Your external IP address is"
 echo $getExternaladdress | $SiriSays
 exit

2: stop ftp service

 #!/bin/bash
 #stop ftp service
 #sudo="/usr/bin/sudo"
 #launchctl="/bin/launchctl"
 networksetup="/usr/sbin/networksetup"
 say="/usr/bin/say"
 tail="/usr/bin/tail"
 head="/usr/bin/head"
 cut="/usr/bin/cut"
 currentInterface=$(networksetup -listnetworkserviceorder |tail +2 |head -n1 |cut -c5-12)
 SiriSays="say -v Samantha"
 #sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
 #your command requires sudo
 if [ "$currentInterface" = "Airport" ]; 
      then
           networksetup -setpassiveftp Airport off
      else
           networksetup -setpassiveftp Ethernet off
 fi
 $SiriSays "ftp service has been terminated"
 exit

3: check ftp service status

 #!/bin/bash
 #check ftp service status
 networksetup="/usr/sbin/networksetup"
 say="/usr/bin/say"
 tail="/usr/bin/tail"
 head="/usr/bin/head"
 cut="/usr/bin/cut"
 currentInterface=$(networksetup -listnetworkserviceorder |tail +2 |head -n1 |cut -c5-12)
 SiriSays="say -v Samantha"
 if [ "$currentInterface" = "Airport" ]; 
      then
           networksetup -getpassiveftp Airport |$SiriSays
      else
           networksetup -getpassiveftp Ethernet |$SiriSays
 fi
 exit

Then apply the appify script to them

What you're left with is three little apps to put in your dock that, when launched, will start or stop the ftp service on your preferred network interface, or tell you what's up with ftp, respectively, and should not require any admin password. I only had time to test the first one, so if they don't work ask I hope they do, then you can comment out or delete my logic and use your launchctl method.