Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Christensen benjamin-dk

View GitHub Profile
@benjamin-dk
benjamin-dk / delete_dir.php
Last active Jun 22, 2017
How to delete directory with PHP on FreeBSD
View delete_dir.php
<?php
/* Its been a while since I used this so please use at your own risk */
function deleteDir($dirPath) {
if (! is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
@benjamin-dk
benjamin-dk / set_locale.sh
Created Sep 19, 2016
Fix perl locale issue on ubuntu 14.04
View set_locale.sh
#!/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
@benjamin-dk
benjamin-dk / setup_letsencrypt_domain.sh
Last active May 25, 2016
Setup Letsencrypt SSL for domain on Virtualmin GPL server setup
View setup_letsencrypt_domain.sh
# 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 / fix-htaccess.sh
Last active Nov 10, 2015
Fix default Drupal .htaccess settings to comply with new Apache (2.4) standards
View fix-htaccess.sh
#!/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 / wp.sh
Last active Aug 29, 2015 — forked from bgallagh3r/wp.sh
Wordpress installation script, customized for FreeBSD
View wp.sh
#!/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 / prefix-dcx.php
Created Jan 14, 2015
Add prefix to MYSQL tables
View prefix-dcx.php
<?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 / wordpress_setup.sh
Last active Aug 29, 2015
Wordpress site setup
View wordpress_setup.sh
#!/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
View 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 / setup_vhost.sh
Last active Dec 18, 2015
Linux bash script for setting up a virtual host on an Apache web server
View setup_vhost.sh
#! /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 / drupal_permissions.sh
Created Jun 4, 2013
Linux bash script for setting correct Drupal permissions in the web folder
View drupal_permissions.sh
#!/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