-
Notifications
You must be signed in to change notification settings - Fork 26
Enhancements for php5-fpm, mysql, etc #3
base: master
Are you sure you want to change the base?
Changes from 1 commit
5748e39
c7e3ce2
b9b6e03
0b6dcbb
480b2d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,10 +74,9 @@ apt-packages-repository() { | |
|
|
||
| # Add a Launchpad PPA as a software source. | ||
| apt-packages-ppa() { | ||
| apt-packages-repository \ | ||
| "deb http://ppa.launchpad.net/$1/ubuntu lucid main" \ | ||
| "deb-src http://ppa.launchpad.net/$1/ubuntu lucid main" \ | ||
| "$2" "$3" | ||
| which 'add-apt-repository' >/dev/null || apt-packages-install 'python-software-properties' | ||
| add-apt-repository "$1" | ||
| apt-packages-update | ||
| } | ||
|
|
||
| # Perform a non-interactive `apt-get` command. | ||
|
|
@@ -98,6 +97,11 @@ apt-packages-update() { | |
| apt-non-interactive update | ||
| } | ||
|
|
||
| # Upgrade `aptitude` packages without any prompts. | ||
| apt-packages-upgrade() { | ||
| apt-non-interactive upgrade | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already available as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually like having both, since you may want to perform a system upgrade, but not a dist upgrade, or maybe indeed a full dist upgrade. Not necessarily as relevant to vagrant (since you could just change your VagrantFile to reference a newer dist image), but relevant within the scope of general server administration if this script were used while managing non-vagrant boxes.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense, however I don't intend for this script to be used for server administration. A full distribution upgrade would also likely involve prompts/dialogs so running non-interactive is going to break the system. |
||
|
|
||
| # Perform an unattended installation of package(s). | ||
| apt-packages-install() { | ||
| apt-non-interactive install "$@" | ||
|
|
@@ -396,18 +400,23 @@ ${code_block} | |
|
|
||
| # Pass PHP scripts to PHP-FPM. | ||
| location ~ \.php\$ { | ||
| fastcgi_pass unix:/var/run/php5-fpm.sock; | ||
| fastcgi_index index.php; | ||
| include fastcgi_params; | ||
| fastcgi_index index.php; | ||
| fastcgi_split_path_info ^(.+\.php)(/.+)\$; | ||
| fastcgi_param PATH_INFO \$fastcgi_path_info; | ||
| fastcgi_param PATH_TRANSLATED \$document_root\$fastcgi_path_info; | ||
| fastcgi_param HTTP_AUTHORIZATION \$http_authorization; | ||
| fastcgi_pass unix:/var/run/php5-fpm-${nginx_site_name}.sock; | ||
| } | ||
| EOD | ||
| ) | ||
| # Run PHP-FPM as the selected user and group. | ||
| $SUDO sed \ | ||
| -e 's#^\(\[[A-Za-z0-9-]\+\]\)$#['"$nginx_site_name"']#g' \ | ||
| -e 's#^\(user\)\s*=\s*[A-Za-z0-9-]\+#\1 = '"$nginx_site_user"'#g' \ | ||
| -e 's#^\(group\)\s*=\s*[A-Za-z0-9-]\+#\1 = '"$nginx_site_group"'#g' \ | ||
| -i '/etc/php5/fpm/pool.d/www.conf' | ||
| -e 's#^\(listen\)\s*=\s*.\+$#\1 = '/var/run/php5-fpm-"$nginx_site_name"'.sock#g' \ | ||
| <'/etc/php5/fpm/pool.d/www.conf' >'/etc/php5/fpm/pool.d/'"$nginx_site_name"'.conf' | ||
| fi | ||
| code_block=$( cat <<-EOD | ||
| ${code_block} | ||
|
|
@@ -460,6 +469,11 @@ php-pecl-install() { | |
| done | ||
| } | ||
|
|
||
| # Restart the php5-fpm server and reload with new configuration. | ||
| php5-fpm-restart() { | ||
| system-service php5-fpm restart | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 3458e89 as |
||
|
|
||
| # }}} | ||
|
|
||
| # {{{ MySQL | ||
|
|
@@ -470,6 +484,20 @@ mysql-database-create() { | |
| mysql -u root -e "CREATE DATABASE IF NOT EXISTS \`$1\` CHARACTER SET ${2:-utf8} COLLATE '${3:-utf8_general_ci}'" | ||
| } | ||
|
|
||
| # Grant access to database (creates user if not exist) | ||
| # mysql-database-add-user databasename username password fromhost | ||
| mysql-database-add-user() { | ||
| log-operation "$FUNCNAME" "$@" | ||
| mysql -u root -e "GRANT ALL PRIVILEGES ON \`$1\`.* TO '$2'@'${4:-localhost}' IDENTIFIED BY '$3' WITH GRANT OPTION; FLUSH PRIVILEGES;" | ||
| } | ||
|
|
||
| # Load data from SQL file | ||
| # mysql-load-data databasename sqlfile | ||
| mysql-load-data() { | ||
| log-operation "$FUNCNAME" "$@" | ||
| mysql -u root "$1" < "$2" | ||
| } | ||
|
|
||
| # Restore a MySQL database from an archived backup. | ||
| mysql-database-restore() { | ||
| log-operation "$FUNCNAME" "$@" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apt-packages-updateshould be included in the provisioning script to allow for batch updates, e.g., adding several PPAs and doing a single update. I've also updatedapt-packages-repositoryto useadd-apt-repositoryso keep the two functions aligned. See 5b46a36.