Install SonarQube

wget https://raw.githubusercontent.com/panticz/installit/master/install.sonarqube.sh -O - | bash -

#!/bin/bash

# install Java
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/installit/master/install.java-jdk.sh -O - | bash -

# install SonarQube
echo "deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/" > /etc/apt/sources.list.d/sonar.list
sudo apt-get update
sudo apt-get install -y --force-yes sonar

# autostart SonarQube
sudo update-rc.d sonar defaults

WebGUI
http://172.29.14.185:9000/

Logfile
tail -f /opt/sonar/logs/sonar.log

Links
http://sonar-pkg.sourceforge.net/
http://docs.sonarqube.org/display/SONAR/Requirements
https://github.com/Godin/sonar-native-packages
https://gist.github.com/micheleorsi/bd20912b2489f3432558

Install SSH VPN server

export CONTAINER=vpn

# create container
# TODO: configure MAC on create container
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/lxc/master/create.jessie.sh -O - | bash -s -- -f

# configure container MAC address
sed -i 's|lxc.network.hwaddr = .*|lxc.network.hwaddr = 00:11:22:33:44:5e|' /var/lib/lxc/${CONTAINER}/config

# enable autostart
echo "lxc.start.auto = 1" | tee -a /var/lib/lxc/${CONTAINER}/config

# configure container
##echo "lxc.hook.autodev=/var/lib/lxc/vpn/autodev" >> /var/lib/lxc/${CONTAINER}/config

Jenkins CLI

# command overview
http://jenkins.example.com:8080/cli/

# add public key for user
http://jenkins.example.com:8080/me/configure

# authentificate by user / pass
java -jar jenkins-cli.jar -s http://jenkins.example.com:8080/ list-jobs --username --password

# install plugin by name
java -jar jenkins-cli.jar -s http://jenkins.example.com:8080/ install-plugin findbugs

# install plugin from URL?
java -jar jenkins-cli.jar -s http://jenkins.example.com:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/AdaptivePlugin/0.1/AdaptivePlugin.hpi

LXC: create Ubuntu Trusty container

wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/lxc/master/create.trusty.sh -O - | bash -s

#!/bin/bash

[ -z ${CONTAINER} ] && CONTAINER=trusty
LANG=en_US.UTF-8

# force, remove previous container
if [ "$1" == "-f" ]; then
  [ $(sudo lxc-ls ${CONTAINER} | wc -l) -gt 0 ] && sudo lxc-destroy -f -n ${CONTAINER}
  shift
fi

# create container
sudo lxc-create -t ubuntu -n ${CONTAINER} -- template-options -r trusty $@

# workaround for "Failed to mount cgroup at /sys/fs/cgroup/systemd: Permission denied"
echo "lxc.aa_profile = unconfined" | sudo tee -a /var/lib/lxc/${CONTAINER}/config

# start container in background
sudo lxc-start -d -n ${CONTAINER}

# wait 3 seconds until network is up
sleep 3

# copy APT proxy configuration from host
APT_PROXY=$(grep -h "Acquire::http::Proxy" /etc/apt/* -r | head -1)
[ -n "${APT_PROXY}" ] && echo ${APT_PROXY} | sudo tee /var/lib/lxc/${CONTAINER}/rootfs/etc/apt/apt.conf.d/01proxy

# update packages in container
sudo lxc-attach -n ${CONTAINER} -- apt-get update
sudo lxc-attach -n ${CONTAINER} -- apt-get dist-upgrade -y

# show containers status
sudo lxc-ls ${CONTAINER} -f

Allow root SSH login with password
sed -i 's|PermitRootLogin without-password|PermitRootLogin yes|' /etc/ssh/sshd_config
sed -i 's|PasswordAuthentication no|PasswordAuthentication yes|' /etc/ssh/sshd_config
service ssh restart

Create UEFI disc

# create disc image
mkfs.msdos -C /tmp/uefi.iso 2880
sudo mount /tmp/uefi.iso /mnt
sudo cp /tmp/your_uefi_files/* /mnt/
sudo umount /mnt
 
# boot to UEFI shell
press F11 on boot
 
# go to UEFI filesystem
fs0:
 
# Links
https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Important_UEFI_Shell_Commands

Debian: Install Cacti

# create container
export CONTAINER=cacti
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/lxc/master/create.jessie.sh -O - | bash -s -- -f
sudo lxc-attach -n ${CONTAINER} -- sed -i 's|PermitRootLogin without-password|PermitRootLogin yes|' /etc/ssh/sshd_config
sudo lxc-attach -n ${CONTAINER} -- service ssh restart

# fix dns
echo nameserver 8.8.8.8 > /var/lib/lxc/${CONTAINER}/rootfs/etc/resolv.conf

# install applications
lxc-attach -n ${CONTAINER} --
LANG=en_US.UTF-8

apt-get update

# server
debconf-set-selections <<\EOF

Install LXD

wget https://raw.githubusercontent.com/panticz/installit/master/install.lxd.sh -O - | bash -

#!/bin/bash

sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:ubuntu-lxc/lxd-stable

# use Ubunut Trusty repository on Utopic
sed -i 's|utopic|trusty|g' /etc/apt/sources.list.d/ubuntu-lxc-ubuntu-lxd-stable-utopic.list

sudo apt-get update
sudo apt-get install -y lxd lxc lxcfs

Links
https://linuxcontainers.org/lxd/getting-started-cli/

Compare zones between two Nameserver

OLD_NS=7.7.7.7
NEW_NS=8.8.8.8
for TYPE in A CNAME MX TXT; do
    for i in $(cat /tmp/example.com.inc | grep ${TYPE} | cut  -f1); do
        OLD=$(dig @${OLD_NS} +short ${TYPE} ${i}.example.com)
        NEW=$(dig @${NEW_NS} +short ${TYPE} ${i}.example.com)
 
        if [ "${NEW}" != "${OLD}" ]; then
            echo ${TYPE} ${i}
            echo OLD: ${OLD}
            echo NEW: ${NEW}
            echo
        fi
    done
done

PostgreSQL

-- enable formated output
\x on
 
-- show tables
\dt
 
-- exit
\q
 
-- Display tables size
/dT+
 
-- connect to mytest database
\c db_name
 
# Links
https://www3.ntu.edu.sg/home/ehchua/programming/sql/PostgreSQL_GetStarted.html
https://www.niwi.nz/2013/02/17/postgresql-database-table-indexes-size/ - SHOW DATABASE, TABLE AND INDEXES SIZE ON POSTGRESQL
https://www.postgresql.org/docs/9.0/static/app-vacuumdb.html
https://www.postgresql.org/docs/9.1/static/app-reindexdb.html

Compile lshw

# install required applications
apt-get -y install build-essential
 
# download and extract
wget http://www.ezix.org/software/files/lshw-B.02.17.tar.gz -P /tmp
tar xzf /tmp/lshw-B.02.17.tar.gz -C /tmp/
 
# compile
cd /tmp/lshw-*/
make
 
# install (optional)
make install
 
# test
lshw -version
 
# executable
/tmp/lshw-*/src/lshw
 
# Links
http://www.ezix.org/project/wiki/HardwareLiSter
Syndicate content