forked from szepeviktor/debian-server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5251847
commit 9c834fe
Showing
13 changed files
with
103 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# Install a tool from debian-server-tools. | ||
# | ||
# VERSION :0.4.2 | ||
# VERSION :0.4.3 | ||
# DATE :2015-05-29 | ||
# AUTHOR :Viktor Szépe <[email protected]> | ||
# LICENSE :The MIT License (MIT) | ||
|
@@ -11,7 +11,7 @@ | |
|
||
|
||
Die() { | ||
local RET="$1" | ||
local -i RET="$1" | ||
|
||
shift | ||
echo -e "$*" 1>&2 | ||
|
@@ -25,11 +25,13 @@ Die() { | |
# META | ||
##################################################### | ||
Get_meta() { | ||
# defaults to self | ||
# Defaults to self | ||
local FILE="${1:-$0}" | ||
# defaults to "VERSION" | ||
# Defaults to "VERSION" | ||
local META="${2:-VERSION}" | ||
local VALUE="$(head -n 30 "$FILE" | grep -m 1 "^# ${META}\s*:" | cut -d':' -f 2-)" | ||
local VALUE | ||
|
||
VALUE="$(head -n 30 "$FILE" | grep -m 1 "^# ${META}\s*:" | cut -d ":" -f 2-)" | ||
|
||
if [ -z "$VALUE" ]; then | ||
VALUE="(unknown)" | ||
|
@@ -87,7 +89,7 @@ Do_install() { | |
|
||
# Create symlink | ||
head -n 30 "$FILE" | grep "^# SYMLINK\s*:" | cut -d ":" -f 2- \ | ||
| while read SYMLINK; do | ||
| while read -r SYMLINK; do | ||
echo -n "Symlinking " | ||
ln -s -v -f "$SCRIPT" "$SYMLINK" || Die 12 "Symbolic link creation failure (${SYMLINK})" | ||
done | ||
|
@@ -103,7 +105,6 @@ Do_install() { | |
Get_meta "$FILE" DEPENDS | sed -n -e 's/^apt-get install \(.\+\)$/\1 /p' \ | ||
| while read -r -d " " PKG; do | ||
if [ "$(dpkg-query --showformat="\${Status}" --show "$PKG" 2> /dev/null)" != "install ok installed" ]; then | ||
#if ! grep-status -sPackage -FProvides "$PKG" | grep -qx "Package: \S\+"; then | ||
echo "MISSING DEPENDECY: apt-get install ${PKG}" 1>&2 | ||
fi | ||
done | ||
|
@@ -131,7 +132,7 @@ Do_dir() { | |
local FILE | ||
|
||
find "$DIR" -maxdepth 1 -type f \ | ||
| while read FILE; do | ||
| while read -r FILE; do | ||
Do_install "$FILE" | ||
done | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# Complete MySQL backup daily. | ||
# | ||
# VERSION :0.1 | ||
# VERSION :0.1.0 | ||
# DATE :2014-10-22 | ||
# AUTHOR :Viktor Szépe <[email protected]> | ||
# LICENSE :The MIT License (MIT) | ||
|
@@ -15,6 +15,6 @@ | |
|
||
BACKUP_TARGET="/root/backup/mysql-today.sql.gz" | ||
|
||
# IO nice and CPU nice | ||
# CPU nice | ||
/usr/bin/mysqldump --all-databases --single-transaction --events \ | ||
| ionice -c 3 nice gzip -9 > "$BACKUP_TARGET" | ||
| nice gzip -9 > "$BACKUP_TARGET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
-- http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html#resetting-permissions-unix | ||
|
||
-- EDIT | ||
SET @my_password = '<PASSWORD>'; | ||
|
||
UPDATE mysql.user SET Password=PASSWORD(@my_password) WHERE User='root'; | ||
FLUSH PRIVILEGES; | ||
|
||
-- $ service mysql stop && mysqld_safe --init-file=/path/to/this/file.sql & | ||
-- service mysql stop && mysqld_safe --init-file=./mysql-reset-pwd.sql & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
#!/bin/bash | ||
# | ||
# Create database and database user from wp-config.php | ||
# Needs user, password and default-character-set in ~/.my.cnf [mysql] section. | ||
# | ||
# VERSION :0.3.0 | ||
# VERSION :0.3.1 | ||
# DATE :2016-02-22 | ||
# AUTHOR :Viktor Szépe <[email protected]> | ||
# LICENSE :The MIT License (MIT) | ||
# URL :https://github.com/szepeviktor/debian-server-tools | ||
# BASH-VERSION :4.2+ | ||
# LOCATION :/usr/local/bin/wp-createdb.sh | ||
# | ||
# Needs user, password and default-character-set | ||
# in ~/.my.cnf [mysql] section. | ||
|
||
WP_CONFIG="./wp-config.php" | ||
|
||
Get_wpconfig_var() { | ||
local VAR="$1" | ||
local DEFAULT="$2" | ||
|
||
# UNIX or Windows lineends | ||
# Support UNIX or Windows line endings | ||
if ! [ -r "$WP_CONFIG" ] || ! grep -q "^define.*${VAR}.*;.\?$" "$WP_CONFIG"; then | ||
if [ -z "$DEFAULT" ]; then | ||
read -r -e -p "${VAR}? " DB_VALUE | ||
|
@@ -34,8 +36,9 @@ Get_wpconfig_var() { | |
grep "^define.*${VAR}.*;.\?$" "$WP_CONFIG" | cut -d"'" -f4 | ||
} | ||
|
||
which mysql &> /dev/null || exit 1 | ||
# Check credentials | ||
hash mysql 2> /dev/null || exit 1 | ||
|
||
# Check database access | ||
mysql --execute="EXIT" || exit 3 | ||
|
||
DBNAME="$(Get_wpconfig_var "DB_NAME")" | ||
|
@@ -57,18 +60,21 @@ echo "Charset: ${DBCHARSET}" | |
echo | ||
read -r -p "CREATE DATABASE? " -n 1 | ||
|
||
[ "$DBHOST" == "localhost" ] || echo "Connecting to ${DBHOST} ..." | ||
if [ "$DBHOST" != "localhost" ]; then | ||
echo "Connecting to ${DBHOST} ..." 1>&2 | ||
fi | ||
|
||
mysql --default-character-set=utf8 --host="$DBHOST" <<EOF || echo "Couldn't setup up database (MySQL error: $?)" 1>&2 | ||
CREATE DATABASE IF NOT EXISTS \`${DBNAME}\` | ||
CHARACTER SET 'utf8' | ||
COLLATE 'utf8_general_ci'; | ||
-- "GRANT ALL PRIVILEGES" creates the user | ||
-- CREATE USER '${DBUSER}'@'${DBHOST}' IDENTIFIED BY '${DBPASS}'; | ||
GRANT ALL PRIVILEGES ON \`${DBNAME}\`.* TO '${DBUSER}'@'${DBHOST}' | ||
GRANT ALL PRIVILEGES ON \`${DBNAME}\`.* | ||
TO '${DBUSER}'@'${DBHOST}' | ||
IDENTIFIED BY '${DBPASS}'; | ||
FLUSH PRIVILEGES; | ||
EOF | ||
|
||
echo -n "wp core config --dbname=\"$DBNAME\" --dbuser=\"$DBUSER\" --dbpass=\"$DBPASS\" " | ||
echo "--dbhost=\"$DBHOST\" --dbprefix=\"prod_\" --dbcharset=\"$DBCHARSET\" # --extra-php <<EOF" | ||
echo -n "wp core config --dbname=\"$DBNAME\" --dbuser=\"$DBUSER\" --dbpass=\"$DBPASS\"" | ||
echo " --dbhost=\"$DBHOST\" --dbprefix=\"prod_\" --dbcharset=\"$DBCHARSET\" # --extra-php <<EOF" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# Show update instruction for installed tools. | ||
# | ||
# VERSION :0.1.1 | ||
# VERSION :0.1.2 | ||
# DATE :2015-07-06 | ||
# AUTHOR :Viktor Szépe <[email protected]> | ||
# LICENSE :The MIT License (MIT) | ||
|
@@ -21,15 +21,17 @@ Get_meta() { | |
local FILE="${1:-$0}" | ||
# defaults to "VERSION" | ||
local META="${2:-VERSION}" | ||
local VALUE="$(head -n 30 "$FILE" | grep -m 1 "^# ${META}\s*:" | cut -d':' -f 2-)" | ||
local VALUE | ||
|
||
VALUE="$(head -n 30 "$FILE" | grep -m 1 "^# ${META}\s*:" | cut -d ":" -f 2-)" | ||
|
||
if [ -z "$VALUE" ]; then | ||
VALUE="(unknown)" | ||
fi | ||
echo "$VALUE" | ||
} | ||
|
||
which colordiff &> /dev/null || unset PARAM | ||
hash colordiff 2> /dev/null || unset PARAM | ||
|
||
#Input_motd Get_meta input/update-motd.d - Get_meta /etc/update-motd.d/update-motd.d | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ ssl: | |
cdn: | ||
enabled: yes | ||
hostname: cdn.example.com | ||
email: | ||
provider: Mailjet | ||
login: [email protected] | ||
cms: | ||
core: WordPress | ||
theme: Theme Name | ||
|
Oops, something went wrong.