Debian: Install MariaDB

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

#!/bin/bash

apt-get install python-software-properties

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
add-apt-repository 'deb http://mirror.netcologne.de/mariadb/repo/10.1/debian wheezy main'
apt-get update

apt-get install -y mariadb-server

Debian Wheezy: Install PHP 5.6

apt-get install -y wget

# install PHP 5.6
echo "deb http://packages.dotdeb.org wheezy-php56 all" > /etc/apt/sources.list.d/dotdeb.org.list
echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.org.list
wget http://www.dotdeb.org/dotdeb.gpg -O - | apt-key add -

apt-get update

apt-get install php5

a2enmod php5
service apache2 restart

Links:
http://www.dotdeb.org/instructions/

WordPress

export CONTAINER=wordpress

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

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.name = eth0
lxc.network.hwaddr = 00:16:3e:f9:d3:03
lxc.network.mtu = 1500

apt-get install -y apache2 mysql-server php5-mysql wget vi php5
# libapache2-mod-auth-mysql

cd /var/www/html
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

# create database
echo "CREATE DATABASE wordpress;" | mysql -u root -proot
echo "CREATE USER wordpressuser@localhost;" | mysql -u root -proot
echo "SET PASSWORD FOR wordpressuser@localhost= PASSWORD('password');" | mysql -u root -proot
echo "GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';" | mysql -u root -proot
echo "FLUSH PRIVILEGES;" | mysql -u root -proot

cp wordpress/wp-config-sample.php wordpress/wp-config.php

sed -i 's|database_name_here|wordpress|' wordpress/wp-config.php
sed -i 's|username_here|wordpressuser|' wordpress/wp-config.php
sed -i 's|password_here|password|' wordpress/wp-config.php

vi wordpress/wp-config.php

#define('WP_ALLOW_REPAIR', true);
#define('DB_CHARSET', 'utf8');

define('DB_CHARSET', 'latin1');
define('FS_METHOD', 'direct');
define( 'WP_MEMORY_LIMIT', '96M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

chown www-data:www-data /var/www/html/wordpress/ -R

http://10.0.3.173/wordpress/wp-admin/install.php

http://10.0.3.173/wordpress/wp-admin/plugin-install.php
Jigoshop

# show errors
# wp-config.php
define('WP_DEBUG', true);

# configuration
UPDATE wp_options
SET option_value = REPLACE(option_value, 'new.example.com', 'www.example.com')
WHERE option_value LIKE '%new.example.com%'

#UPDATE wp_options SET `option_value` = 'you@example.com' WHERE `wp_options`.`option_id` = 5;
#UPDATE wp_users SET user_email = 'you@example.com' WHERE ID = 1;

# reset password
UPDATE wp_users SET user_pass = MD5('new_pass') WHERE ID = 1;

# wordpress extract script
# wi.php

# fix URL
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'new.example.com', 'www.example.com')
WHERE post_content LIKE '%new.example.com%'

UPDATE wp_posts
SET guid = REPLACE(guid, 'new.example.com', 'www.example.com')
WHERE guid LIKE '%new.example.com%'

# set file permissions
system("find . -type d -exec chmod 755 {} \;");
system("find . -type f -exec chmod 644 {} \;");

# Links
https://wiki.debian.org/WordPress
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-12-04
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04
https://wiki.debian.org/WordPress
http://wpde.org/e-commerce/
http://steellounge.de/
https://www.jigoshop.com/getting-started-guide/

DMA (Dragonfly Mail Agent)

# ansible role
https://github.com/panticz/ansible/tree/master/roles/dma

# preconfigure
echo "dma dma/relayhost string mail.example.com" | debconf-set-selections
echo "ddm dma/mailname string $(hostname -A)" | debconf-set-selections

# install
apt-get install -y dma

# configure relayhost
echo "foo|mail.example.com:bar" >> /etc/dma/auth.conf

# send testmail
echo "This is a test message from ${USER}@${HOSTNAME} at $(date)" | /usr/sbin/sendmail foo@exaple.com

Configuration files
# /etc/dma/dma.conf
AUTHPATH /etc/dma/auth.conf
SMARTHOST smtp.strato.de

Use ecrypted home directory and sshuttle

sudo apt-get install -y ecryptfs-utils

sudo adduser --encrypt-home foo

ecryptfs-mount-private foo

sudo usermod -aG sudo foo

sudo apt-get install -y sshuttle

su - foo
sshuttle --dns -r foo@example.com 10.0.0.0/8 -x 192.168.1.0/24

LXC: Installation under Ubuntu / Debian

wget --no-check-certificate https://raw.githubusercontent.com/panticz/installit/master/install.lxc.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

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

# fix dist name
for FILE in $(find /etc/apt/sources.list.d/ -name "*lxc*.list"); do
  sed -i 's|jessie|trusty|g;s|utopic|trusty|g' ${FILE}
done

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

if [ "$1" == "-b" ]; then
  # install required packages
  apt-get install -y bridge-utils

  # disable auto configuration for eth0
  sed -i 's|auto eth0|#auto eth0|g' /etc/network/interfaces
  sed -i 's|iface eth0 inet dhcp|#iface eth0 inet dhcp|g' /etc/network/interfaces

# create network bridge
cat <<EOF>> /etc/network/interfaces
auto lxcbr0
iface lxcbr0 inet dhcp
  bridge_ports eth0
EOF

  # disable auto configuration for network bridge by lxc
  [ -f /etc/default/lxc-net ] && sed -i 's|USE_LXC_BRIDGE="true"|USE_LXC_BRIDGE="false"|g' /etc/default/lxc-net
  
  # disable network managed by NetworkManager when installed
  [ -f /etc/NetworkManager/NetworkManager.conf ] && sed -i 's|managed=true|managed=false|g' /etc/NetworkManager/NetworkManager.conf
fi

# allow all user to list the containers
[ -d /etc/sudoers.d/ ] && echo "ALL ALL=NOPASSWD: /usr/bin/lxc-ls" >> /etc/sudoers.d/lxc

# install under Debian Jessie
apt-get install bridge-utils
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/installit/master/install.lxc.sh -O - | bash -s -- -b
#wget http://mirrors.kernel.org/ubuntu/pool/main/l/lxc/lxc_1.0.7-0ubuntu0.2_amd64.deb -P /tmp/
#dpkg -x /tmp/lxc_1.0.7-0ubuntu0.2_amd64.deb /tmp/
#cp -a /tmp/etc/* /etc/

# Check kernel configuration
lxc-checkconfig

systemd

systemctl
systemctl enable late_command.service
systemctl disable late_command.service
systemctl status late_command.service
journalctl -f
systemd-analyze verify

Example
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/preseed/master/late_command.service -O /etc/systemd/system/late_command.service && \
systemctl enable late_command.service

[Unit]
Description=preseed late_command script
After=network.target

[Service]
StandardOutput=tty
ExecStartPre=/usr/bin/wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/preseed/master/late_command.sh -O /tmp/late_command.sh
ExecStart=/bin/bash /tmp/late_command.sh
ExecStartPost=/bin/systemctl disable late_command.service

[Install]
WantedBy=multi-user.target

# test
[Unit]
After=getty.target

[Service]
TTYPath=/dev/tty1

# test
journalctl -xn
systemctl list-unit-files --all

Links
https://wiki.ubuntuusers.de/systemd/
https://wiki.ubuntuusers.de/systemd/Service_Units/
http://www.freedesktop.org/software/systemd/man/systemd.service.html
https://wiki.archlinux.org/index.php/Systemd_FAQ
https://wiki.ubuntu.com/SystemdForUpstartUsers
http://www.freedesktop.org/software/systemd/man/systemd.special.html

GitLab: Web-based Git repository manager

Install
http://www.panticz.de/install-gitlab

# restart gitlab
gitlab-ctl restart

# git home directory
/var/opt/gitlab

Reset admin password
gitlab-rails console production
u = User.where(id: 1).first
u.password = 'secret'
u.password_confirmation = 'secret'
u.save!

backup
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
# full backup
gitlab-rake gitlab:backup:create

# backup without reposiories
sudo gitlab-rake gitlab:backup:create SKIP=repositories

# backup target

Linux Kernel

#
# configure parameter
#
# determine the maximum size of a shared memory segment
cat /proc/sys/kernel/shmmax
 
# set default shared memory limit for shmmax (16 GB)
echo 17179869184 > /proc/sys/kernel/shmmax
 
# add the following line to /etc/sysctl.conf to make a change permanent
echo "kernel.shmmax=4294967296" >> /etc/sysctl.d/90-shmmax.conf
 
# load parameter
/sbin/sysctl -p /etc/sysctl.d/90-shmmax.conf
Syndicate content