Skip to content

Instantly share code, notes, and snippets.

View benjamin-dk's full-sized avatar

Benjamin Christensen benjamin-dk

  • Aarhus Universitetshospital
View GitHub Profile
@benjamin-dk
benjamin-dk / create_database.sh
Last active December 18, 2015 01:29
Linux bash script for setting up a new database and database user in MySQL
#!/bin/bash
# Command should follow this pattern: ./createdb testdb testuser secretpass
BTICK='`'
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
echo "You will be prompted your mysql root password."
@benjamin-dk
benjamin-dk / drupal_permissions.sh
Created June 4, 2013 08:25
Linux bash script for setting correct Drupal permissions in the web folder
#!/bin/bash
#Securing file permissions and ownership: http://drupal.org/node/244924
#run the script as follows: sudo bash drupal_permissions.sh your/drupal/path your_user_name
path=${1%/}
user=${2}
group="www-data"
help="\nHelp: This script is used to fix permissions of a drupal installation\nyou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2) Username of the user that you want to give files/directories ownership\nNote: \"www-data\" (apache default) is assumed as the group the server is belonging to, if this is different you need to modify it manually by editing this script\n\nUsage: (sudo) bash ${0##*/} drupal_path user_name\n"
if [ -z "${path}" ] || [ ! -d "${path}/sites" ] || [ ! -f "${path}/modules/system/system.module" ]; then
@benjamin-dk
benjamin-dk / setup_vhost.sh
Last active December 18, 2015 01:29
Linux bash script for setting up a virtual host on an Apache web server
#! /bin/bash
#
# =======================
# Siteup Script 0.1
# Written by Command Line Idiot
# http://commandlineidiot.com
# You may use, modify, and redistribute this script freely
# Released: August 2007
# =======================
@benjamin-dk
benjamin-dk / Wordpress permissions
Last active March 7, 2023 18:52
Script for setting up correct Wordpress permissions by Mike Conigliaro http://www.conigliaro.org/2010/05/06/script-to-configure-proper-wordpress-permissions/
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
@benjamin-dk
benjamin-dk / wordpress_setup.sh
Last active August 29, 2015 13:57
Wordpress site setup
#!/bin/bash
#
# By http://www.rosehosting.com/blog/script-install-wordpress-on-a-debianubuntu-vps/
# Install WordPress on a Debian/Ubuntu VPS
#
 
# Create MySQL database
read -p "Enter your MySQL root password: " rootpass
read -p "Database name: " dbname
read -p "Database username: " dbuser
@benjamin-dk
benjamin-dk / prefix-dcx.php
Created January 14, 2015 23:44
Add prefix to MYSQL tables
<?php
/**
* MySQL Table Prefix Changer DXC Version
* By deuxcode.com
* Version 10.6.3
*
* This is a modified version of R.Dunham's script. Original details below.
*
* New in this version:
* Possibility to specify current prefix which gives us the power to
@benjamin-dk
benjamin-dk / wp.sh
Last active August 29, 2015 14:13 — forked from bgallagh3r/wp.sh
Wordpress installation script, customized for FreeBSD
#!/bin/sh
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
@benjamin-dk
benjamin-dk / fix-htaccess.sh
Last active November 10, 2015 08:37
Fix default Drupal .htaccess settings to comply with new Apache (2.4) standards
#!/bin/bash
# Searches the current working directory recursively and replaces old symlink-setting with the new
read -p "This script should be run from the Drupal root folder to work properly. Is this our current location?" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
curdir=$(pwd)
@benjamin-dk
benjamin-dk / setup_letsencrypt_domain.sh
Last active May 25, 2016 10:54
Setup Letsencrypt SSL for domain on Virtualmin GPL server setup
# Warning: use this script at your own risk - work in progress. Tested on Ubuntu 14.04 server.
# Note: Now that the letsencrypt feature is in place in Virtualmin, this script is obsolete.
# Before running the script, be sure to have Letsencrypt installed in /opt/ as descripted in the guide below:
# https://www.virtualmin.com/node/38853
# Running Drupal on the site? Remember to adjust .htaccess as described in the link below:
# https://community.letsencrypt.org/t/drupals-defualt-htaccess-file-breaks-webroot-authentication/3014
# Other resources:
# https://joealdeguer.com/how-to-install-and-setup-letsencrypt-for-virtualmin/
@benjamin-dk
benjamin-dk / set_locale.sh
Created September 19, 2016 09:42
Fix perl locale issue on ubuntu 14.04
#!/bin/bash
# credits: https://jee-appy.blogspot.dk/2016/02/set-locale-on-ubuntu-permanent-solution.html
# Set locales in /etc/default/locale file
echo "Setting locale..."
echo "# Locale settings
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile