Jump to content

Search the Community

Showing results for tags 'Apache'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
  • Alfred v2 Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting

Categories

  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Twitter


Website URL


Jabber


Location


Interests

Found 1 result

  1. Sorry this is long - but it is a bit complex. I intermittently do web development work and prefer to develop it all on my local machine, but don't want Apache & MySQL running all the time. So I thought I'd make a quick workflow to allow me to start, stop and restart these services. The normal procedure would be to open Terminal and type: sudo apachectl stop password sudo mysql.server stop no password 2nd time because it's good for 5 minutes. Substitute start or restart as necessary. * This assumes you have set up your paths correctly (use sudo vi /etc/paths), otherwise you will need to type: sudo /usr/local/mysql/support-files/mysql.server stop and the equivalent for apache So, I made a quick keyword workflow with a required argument (your password) which is passed to a script like: echo "{query}" | sudo -S apachectl stop Unfortunately it doesn't work. I double checked the sudo man pages, looked around the Internet and found others who said this was the way to script sudo commands requiring a password. Still no luck in Alfred. Probably for the best in the long term, I gave up on that and took the steps to set up my machine to do this properly. I was trying to do it this way so that the workflow could be portable to other machines without any other steps (and soothed my conscious about scripts with plain text passwords by telling myself that it wasn't stored anyplace). So here's my question. Would a workflow like this be desirable/of use to others if it requires a little work of a somewhat esoteric nature to set up your computer properly to work? Specifically it requires that you edit your sudoers file (sudo visudo) to allow you to run these specific commands without a password. Here's what my sudoers file looks like now: # sudoers file. # # This file MUST be edited with the 'visudo' command as root. # Failure to use 'visudo' may result in syntax or file permission errors # that prevent sudo from running. # # See the sudoers man page for the details on how to write a sudoers file. # # Host alias specification # User alias specification # Cmnd alias specification Cmnd_Alias ASTART = /usr/sbin/apachectl start Cmnd_Alias ASTOP = /usr/sbin/apachectl stop Cmnd_Alias ARESTART = /usr/sbin/apachectl restart Cmnd_Alias MYSTART = /usr/local/mysql/support-files/mysql.server start Cmnd_Alias MYSTOP = /usr/local/mysql/support-files/mysql.server stop Cmnd_Alias MYRESTART = /usr/local/mysql/support-files/mysql.server restart Cmnd_Alias WEBCTL = ASTART,ASTOP,ARESTART,MYSTART,MYSTOP,MYRESTART # Defaults specification Defaults env_reset Defaults env_keep += "BLOCKSIZE" Defaults env_keep += "COLORFGBG COLORTERM" Defaults env_keep += "__CF_USER_TEXT_ENCODING" Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE" Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME" Defaults env_keep += "LINES COLUMNS" Defaults env_keep += "LSCOLORS" Defaults env_keep += "SSH_AUTH_SOCK" Defaults env_keep += "TZ" Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY" Defaults env_keep += "EDITOR VISUAL" Defaults env_keep += "HOME MAIL" # Runas alias specification # User privilege specification root ALL=(ALL) ALL %admin ALL=(ALL) ALL aviris mycomputername=(root)NOPASSWD:WEBCTL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL Rather than doing the command aliases, you could just put multiple lines under the User privilege specification. Once the sudoers file is setup properly the workflow is dead simple, just two lines issuing the start, stop, or restart commands (made simpler if you have set up the paths file). I'm still thinking on the best way to query the two servers afterward to be able to provide some feedback. Right now I just have it open a phpinfo page at localhost and if I see it, then it started/restarted. If it says it can't connect, it stopped. I'm no programmer, so maybe there are ways to do this sort of thing using PHP (looks at David Ferguson), but as I'm writing this I'm thinking of several other things I could do with Alfred and the sudoers file. Looking through the forum I didn't see any workflows using sudo commands so maybe I'm missing something. You'll notice I didn't use any *'s anyplace or do anything crazy like make an Alfred group and say members can do anything without a password, but the potential is there I suppose. So that brings me back to my question about making and sharing workflows that require mucking about with some potentially sensitive settings. Thoughts?
×
×
  • Create New...