Linux shell – Disk space commands

Find all files 100Mb and great in root

find / -xdev -type f -size +100M

Show current directory disk space usage, this filesystem only, and only at one level (but counts all files in the subfolders)

du -hx --max-depth=1

As above, but sort largest folders/files to the bottom of the list

du -hx --max-depth=1 | sort -h

Laravel and Docker

Laravel is a PHP framework that makes building a web application faster (once you climb the mountain to learn it!)

Docker is the hosting environment that brings your ‘development’ and ‘production’ environments closer together.

Laradock is the glue holding them together.

Getting started with Laravel for Linux System Administrators

I recently had a go at learning Laravel.

I’m already very familiar with Linux servers as I ran a web hosting business. Yet all the Getting started documents seemed to assume I was unfamiliar and lead me down the path of using Vagrant on my Windows desktop

To use Laravel on a Linux web hosting account, all you actually need is composer. This is a PHP dependency manager, not unlike Yum or Apt-get you would use to manage packages on your server.

You can install composer with the standard package management. From there create a new Laravel project with

composer create-project –prefer-dist laravel/laravel blog

in the folder where you would like it created, where blog is the name of the new project.

This creates a project using the initial laravel files.

Once thats done you have a very basic laravel website ready to go. Place it behind an apache web server and you should see the logo of laravel.

Anouther important piece is the artisan file. This command line PHP script performs a few important functions such managing the associated database for the laravel site in an intelligent way.

Quick build a new Windows PC

Boxstarter offers a way to take a new PC with an internet connection and have it auto load software from a software respoistory. Here are some sample links I put together. You can view what they do by putting the loaded URL into a browser. The process works without any software loaded only in IE and Edge browsers.

http://boxstarter.org/package/nr/url?http://hansenit.solutions/build

http://boxstarter.org/package/nr/url?http://hansenit.solutions/builddev

http://boxstarter.org/package/nr/url?http://hansenit.solutions/buildserver

Services

Hansen IT Solutions can provide a range of services.

Website development and ongoing maintenance

Search engine optimisation

Social media integration and management

SMB Desktop networking design, services and support

Internet connectivity

VoIP Telephony including PABX systems and integration

Custom programming services

Adding slave DNS servers for Plesk

There is a nice and simple extension for Plesk that allows you to setup slave DNS zones from Plesk domains automatically.

If your adding this to an existing server though its a little hit and miss if it will add existing domains. The instructions say you can do this via ‘Apply DNS template’ but this did not work for me. Adding new domains worked fine though.

I ended up writing this script and it worked great.

add-slave.sh
#!/bin/bash
/usr/sbin/rndc -c /usr/local/psa/var/modules/slave-dns-manager/slave_*SLAVEIP*>.conf addzone $1 '{ type slave; file "db.'$1'"; masters { *MASTERIP*; }; };'

Replace *MASTERIP* and *SLAVEIP* with your own server IPs.

Usage from the command line is just needs a the DNS your setting up the slave with as the parameter

Taking it further there was a few hundred domains which didnt seem fun to type in one at a time so I used this script to loop over all the domains and add each one.


#!/bin/sh

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk ‘{print $2}’`
mysql=”${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa”

query=”select name from domains;”
domains=`echo $query | $mysql `

for i in ${domains}; do
./add-slave.sh $i
done

from https://gist.github.com/agarzon/37b6eac3f31a5017ffb2 which was linked in the comments.