Jump to content

Search the Community

Showing results for tags 'mysql'.



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 4 results

  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?
  2. Is it possible to make a snippet that would have a date format such as: %Y-%m-%d in the snippet. For example, I'd like to make a snippet that would have embedded in the paragraph that expands, a date that would be today's date or maybe a date that would be 10 days from now. I tried to put '%Y-%m-%d' into the expanded sentence after the keyword is pressed but all that happened was %Y-%m-%d showed up in the middle of the sentence. So, is it possible to do this or perhaps not. It's not a "do or die" thing with me. Alfred is really looking great and to do this would really bring a smile to my face. Thanks for any help.
  3. Workflow to toggle Localhost Services (Start, Stop, Restart and Check Status). Currently support Nginx, MySQL, PHP-fpm and memcached. Download here: Github
  4. Hi all! So I'm finally getting around to doing my very own workflow programming and I've run into some weirdness creating a Workflow that Runs a Bash Script in Alfred v2. I've tested this bash script on the command line and it works a treat. In fact, most of the workflow works in Alfred but a couple of things are funky: When using \n inside my echo commands it literally prints \n instead of using a new line. I'd like to format my virtual hosts files as I have them now. It's even more critical for /etc/hosts where that needs to on a new line. When running the mysql logic - It doesn't create the database. It will, however, start MySQL which is something. Note I have tried to both make the commands sequential and used the && distinction. Neither works. The long and short of this is that basically I am creating a new local site on my stack. I create a directory, a virtual host entry, an /etc/hosts entry, and a MySQL database. Simple enough. I am sure this is due to my being very new to Alfred workflows. Probably something silly. Any help you can offer would be appreciated greatly. Interpreter is /bin/bash - All of the escapes are checked in the workflow window (Backslashes, Brackets, etc.) and the whole script looks like this... site="{query}" # Create a new directory mkdir ~/Sites/$site # Create a new entry in the Apache virtual hosts file. echo "\n<VirtualHost *:80>" >> ~/Sites/httpd-vhosts.conf echo " ServerName $site.localhost" >> ~/Sites/httpd-vhosts.conf echo " DocumentRoot \"/Users/ksilanskas/Sites/$site\"" >> ~/Sites/httpd-vhosts.conf echo " ErrorLog \"/Users/ksilanskas/Sites/Logs/$site-errors.log\"" >> ~/Sites/httpd-vhosts.conf echo "</VirtualHost>" >> ~/Sites/httpd-vhosts.conf # Ensure MySQL is running and then create the database. mysql.server start >> /dev/null && echo "CREATE DATABASE $site" | mysql -u root -proot >> /dev/null # Add an entry to the /etc/hosts file and restart Apache osascript -e "do shell script \"sudo echo '127.0.0.1 $site.localhost' >> /etc/hosts && sudo apachectl restart >/dev/null\" with administrator privileges" Thanks again! P.S. To prove I did a little searching... I did find this but it didn't look like a complete topic... http://www.alfredforum.com/topic/879-create-mysql-database-from-script-action/?hl=mysql - I'd prefer to just stick with using command line on this one if possible.
×
×
  • Create New...