Operating system installation guide/manual

Table of Contents

1 Installations

1.1 Operating system installation

At the reference base os is Ubuntu 14.10.

1.2 Minimal application base

After the operating system is installed, do an upgrade right away:

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove && sudo apt-get clean

Then always install (and never forget):

sudo apt-get install \
             git \
             mercurial \
             ssh \
             curl \
             ncurses-term \
             language-pack-en language-pack-sv

1.3 Additional package repositories

Find more ppas here.

1.3.1 CLI/Server applications

Git stable

sudo apt-add-repository -y ppa:git-core/ppa

Postgresql official apt repository…

add their key

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

note the ubuntu release code name

lsb_release -c

create /etc/apt/sources.list.d/pgdg.list:

deb http://apt.postgresql.org/pub/repos/apt/ RELEASECODENAME-pgdg main

Docker

sudo apt-get remove lxc-docker
sudo apt-get install linux-image-extra-`uname -r`
curl -sSL https://get.docker.com/ | sh

1.3.2 X/Desktop

recoll (desktop indexing)

sudo apt-add-repository -y ppa:recoll-backports/recoll-1.15-on

1.3.3 Update/Upgrade

After adding the ppas:

sudo apt-get update && sudo apt-get dist-upgrade

1.4 Programming languages: development / runtimes

When developing and/or deploying apps with lot's of different languages, versions and so on it is important to be able to control these environments tightly to make them as replicable as possible. I try to always manage an environment per project set up with different levels of isolation depending on the project needs. Also I try to always install at a user level so that operating system upgrades and so on won't interfere with the projects. An added bonus of installing to ~ is that the risk of messing up the OS by installing broken or semi broken packages further reduced.

Here follows a set of instruction of doing installations of the development chains I mainly use…

1.4.1 Development runtimes dependencies

As a preparation for building these you probably want the development headers for the following libraries installed.

sudo apt-get install \
             autoconf \
             build-essential \
             intltool \
             libpcre3-dev \
             libreadline-dev \
             libssl-dev \
             libtool \
             libxml2-dev \
             libxslt1-dev \
             ncurses-dev \
             python-dev \
             ruby-dev

1.4.2 Languages and tools

1.4.2.1 Node

Node version manager for managing multiple node js installations

Fetch and activate nvm

mkdir -p ~/.opt \
      && git clone git://github.com/creationix/nvm.git ~/.opt/nvm \
      && . ~/.opt/nvm/nvm.sh

Install node 0.12

nvm install v0.12.0

Set default version

nvm alias default 0.12

install coffee-script and some other commonly used runtimes: (NOTE: the upgradeall script is in dotfiles-base)

upgradeall npm
1.4.2.2 Python

Just install virtualenvwrapper globally:

sudo apt-get install python-pip
sudo pip install pip --upgrade
sudo pip install virtualenvwrapper

Create a default virtualenv:

source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv --system-site-packages --prompt="(d)" default

Possibly remove old virtualenv burrito content if that was installed previously:

rm -rf ~/.venvburrito/
1.4.2.3 Haskell

Install haskell from apt:

sudo apt-get install \
             ghc ghc-doc \
             haskell-doc \
             cabal-install \
             darcs

Update cabal index

cabal update

Update cabal

cabal install cabal-install

Add cabal bin to path

export PATH="${HOME}/.cabal/bin:${PATH}"

Update cabal index (dunno if its needed)

cabal update

install happy (used for ghc-mod used by emacs ghc-mod package)

cabal install happy

install ghc-mod (dev tool used by emacs ghc-mod package)

cabal install ghc-mod
1.4.2.4 Java

The JVM and OpenJDK is quite stable. Gradle and maven are usually enough to handle per project dependencies.

Install Open JDK and basic java development tool

sudo apt-get install \
             openjdk-8-jre openjdk-8-jdk openjdk-8-source openjdk-8-doc \
             ant ant-optional ant-contrib

Check whats the default jdk

sudo update-alternatives --config java
1.4.2.5 Maven
mkdir -p ~/.opt \
      && cd ~/.opt \
      && wget http://apache.mirrors.spacedump.net/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz \
      && tar -xf apache-maven-3.3.3-bin.tar.gz \
      && ln -s apache-maven-3.3.3 apache-maven
1.4.2.6 Gradle
mkdir -p ~/.opt \
      && cd ~/.opt \
      && wget http://services.gradle.org/distributions/gradle-2.4-all.zip \
      && unzip gradle-2.4-all.zip \
      && ln -s gradle-2.4 gradle
1.4.2.7 Clojure

Leiningen is already installed in dotfiles-base ~/.bin

1.4.2.8 Supercollider

SuperCollider

I really really should compile SC locally since stuff has become broken before

Super collider base: Install SuperCollider

sudo apt-get install \
             supercollider \
             supercollider-emacs \
             jack-tools qjackctl \

Overtone:

Overtone is a SuperCollider api for Clojure…

1.4.2.9 Golang

Installation of latest Go release into ~/.opt/go

Fetch the latest go release

mkdir -p ~/.opt && git clone https://go.googlesource.com/go ~/.opt/go
cd ~/.opt/go && git checkout go1.4.2

Compile and install Go

cd ~/.opt/go/src && ./all.bash

Prepare gopath for installing some common go tools

INSTALLDIR=~/repos/go
mkdir -p ${INSTALLDIR}/bin/
GOPATH=${INSTALLDIR}
export GOPATH
export PATH="$GOPATH/bin:${PATH}"

Install various tools using upgradeall (from dotfiles-base)

upgradeall goget
1.4.2.10 PHP

lolphp

sudo apt-get install \
             php5-fpm
1.4.2.11 TODO codesearch
go get code.google.com/p/codesearch/cmd/{cindex,csearch}
go install code.google.com/p/codesearch/cmd/{cindex,csearch}

1.5 Software packages installation

1.5.1 Cli/server applications

1.5.1.1 Development

Install development, build and source code management tools

sudo apt-get install \
             git git-svn \
             mercurial \
             subversion subversion-tools

Python based tools installed by pip

pip install --upgrade \
    git-goggles \
    bumpversion \
    git-up \
    autopep8 \
    devpi-client \
    tox \
    detox \
    docker-compose \
    mkdocs
1.5.1.2 Document/text tools

Install highlight

sudo apt-get install \
             source-highlight

Install spelling dictionaries

sudo apt-get install \
             aspell-sv \
             aspell-en

Install TeX-related tool chains (only install if really going to use >1gb)

sudo apt-get install \
             texlive-full

Diagramming tools

sudo apt-get install \
             graphviz

Install haskell built packages

cabal install \
      pandoc

Install using python package installer (PIP)

pip install --upgrade \
    pygments \
    sphinx

Install ruby built packages

sudo gem install sass

Install languagetool (spelling/grammar checker)

mkdir -p ~/.opt \
      && cd ~/.opt \
      && wget https://www.languagetool.org/download/LanguageTool-2.9.zip \
      && unzip LanguageTool-2.9.zip \
      && ln -s LanguageTool-2.9 LanguageTool
  1. NEXT offlineimap
    mkdir -p ~/.opt \
          && git clone https://github.com/thomasf/offlineimap  ~/.opt/offlineimap \
          && mkdir -p ~/.bin-local/ \
          && ln -fs ~/.opt/offlineimap/offlineimap.py ~/.bin-local/offlineimap
    
  2. NEXT mu/mu4e

    Download

    mkdir -p ~/.opt \
          && git clone https://github.com/thomasf/mu  ~/.opt/mu
    

    configure / make

    ...
    
  3. NEXT dunst

    TODO: libs are missing

    :ID: db000b01-a985-44f4-b023-36ac5d751413

    mkdir -p ~/.opt && \
          git clone https://github.com/thomasf/dunst ~/.opt/dunst
    
    cd dunst
    make
    sudo make install
    
1.5.1.3 cli utilities
sudo apt-get install \
             htop \
             saidar \
             dstat \
             nmap \
             tmux \
             tree \
             gnutls-bin
1.5.1.4 Multimedia processing tools
sudo apt-get install \
             imagemagick \
             flac \
             lame \
             gifsicle \
             optipng \
             libimage-exiftool-perl

1.5.2 X/Desktop apps

1.5.2.1 Udevil (rootless mounting of removable media)

Grab latest package from: https://github.com/IgnorantGuru/udevil/tree/master/packages

Something like this:

sudo apt-get install \
             intltool \
             libudev-dev \
             libglib2.0-dev

udevilv="0.4.1" \
 && curl -L https://github.com/IgnorantGuru/udevil/blob/master/packages/${udevilv}/udevil_${udevilv}-1_all.deb?raw=true > udevil_${udevilv}-1_all.deb \
 && sudo dpkg -i udevil_${udevilv}-1_all.deb
1.5.2.2 Google chrome

Install Dependencies

sudo apt-get install \
             libnss3-1d

For Chrome stable:

(curl https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb> /tmp/chrome.deb ) &&
sudo dpkg -i /tmp/chrome.deb &&
rm /tmp/chrome.deb

For Chrome beta

(curl https://dl.google.com/linux/direct/google-chrome-beta_current_$(dpkg --print-architecture).deb> /tmp/chrome.deb ) &&
sudo dpkg -i /tmp/chrome.deb &&
rm /tmp/chrome.deb

Setting one of the chromes as default chrome:

sudo update-alternatives --set google-chrome /usr/bin/google-chrome-beta
1.5.2.3 Network/web
sudo apt-get install \
             chromium-browser\
             transmission-gtk \
             firefox
1.5.2.4 Multimedia

vlc

sudo apt-get install \
             vlc \
             mplayer \
             gstreamer0.10-plugins-good \
             gstreamer0.10-plugins-bad

xbmc

sudo apt-get install \
             xbmc

kmidimon

sudo apt-get install \
             kmidimon
1.5.2.5 GUI utilities
sudo apt-get install \
             krusader \
             kdiff3 \
             keepassx \
             git-gui gitk
sudo apt-get install \
             pgadmin3

mysql-admin and mysql-query-browser has sadly been deprecated and is replaced with something horrible :/

1.5.2.6 Nvidia drivers

Install current nvida drivers

sudo apt-get install \
             nvidia-current \
             nvidia-185-libvdpau
1.5.2.7 TODO Manual install

Dropbox (use server version) https://www.dropbox.com/install

# Install dropbox 64BIT!
cd ~ && wget -O - http://www.dropbox.com/download?plat=lnx.x86_64 | tar xzf -
# Daemon needs to be started manually:
# ~/.dropbox-dist/dropboxd

1.5.3 Mixed/other

1.5.3.1 Music player daemon + related
  1. Basic music player daemon and a a couple of cli clients
    sudo apt-get install \
                 mpd \
                 mpc \
                 ncmpcpp
    
  2. Music player daemon gtk ui
    sudo apt-get install \
                 sonata
    
  3. Last.fm submission

    I use scmpc for this. It's not available in the ubuntu (12.04) repositories.

    Installing a recent version of libmpdclient from source might be necessary.

    git clone git://git.musicpd.org/master/libmpdclient.git/ libmpdclient
    
    cd libmpdclient
    
    ./autogen.sh
    
    make
    
    sudo make install
    

    Installing scmp from source.

    git clone https://github.com/cmende/scmpc
    
    cd scmpc
    
    ./autogen.sh
    
    make
    
    sudo make install
    

1.6 ~ sync

I synchronize all my ~ on different systems using git. This is how to fetch and install the repository.

1.6.1 From private repositories

Fetch ssh keys and load ssh agent with key

scp a00001@medeltiden.org:.ssh/id_rsa PRIVATE_SSH_KEY &&
    chmod 600 PRIVATE_SSH_KEY &&
    eval `ssh-agent` && ssh-add PRIVATE_SSH_KEY

Clone base repositories

repos="base emacs private notes experimental blobs" &&
  base="git@medeltiden.org:private/thomasf/home/" &&
  mkdir -p ~/.config/dotfiles && cd ~/.config/dotfiles &&
  for repo in $repos; do git clone $base$repo; done

Clone desktop repositories

repos="xmonad" &&
  base="git@medeltiden.org:private/thomasf/home/" &&
  mkdir -p ~/.config/dotfiles && cd ~/.config/dotfiles &&
  for repo in $repos; do git clone $base$repo; done

Add publish remotes

base="git@github.com:thomasf/dotfiles-thomasf-" &&
  repos="base emacs xmonad" &&
  cd ~/.config/dotfiles &&
  for repo in $repos; do ([ -d $repo ] && cd $repo && git remote add publish $base$repo); done

Install with hsadmin

./base/.bin/hsadmin -f install &&
./base/.bin/home-fix

1.6.2 From public sources

Clone all repositories using git

repos="base emacs" &&
  base="https://github.com/thomasf/dotfiles-thomasf-" &&
  mkdir -p ~/.config/dotfiles && cd ~/.config/dotfiles &&
  for repo in $repos; do git clone $base$repo $repo; done

Install with hsadmin

./base/.bin/hsadmin -f install &&
./base/.bin/home-fix

Set up the prompt by creating a .bashrc-private file

emacs ~/.bashrc-private

Template for ~/.bashrc-private

# -*- ... mode: sh; ... -*-

__user_alias() {
    local u=`whoami`
    case $u in
        root)
            echo -n "###"
            ;;
        a00001)
            echo -n ".1"
            ;;
        thomasf)
            echo -n ".t"
            ;;
        *)
            echo -n "$u"
            ;;
    esac
}

#HOST_TAGS=":workstation:"
HOST_TAGS=":server:"
export HOST_TAGS

HOST_ALIAS="I_FORGOT_TO_SET_HOST_ALIAS"
export HOST_ALIAS

1.7 Emacs

Emacs is my main text/programming editor. My ~/.emacs.d/ configuration requires emacs 24.3 to function properly.

Install build dependencies:

# the following dependencies or similar are required to build
sudo apt-get install \
             libgtk-3-dev \
             libgif-dev \
             libxpm-dev \
             texinfo \
             libtiff5-dev \
             libxaw7-dev \
             librsvg2-dev \
             libmagickwand-dev \
             libgpm-dev \
             libgnutls-dev \
             libotf-dev \
             libm17n-dev \
             libacl1-dev

build emacs using the script in emacs.d

cd ~/.emacs.d
./installDeps emacs

1.7.1 OPTIONAL Install emacs-eclim

NOTE: only for java, also might not work

Install docs

Download the following:

install

extract archives

cd ~/.opt
tar -xf ~/Downloads/eclipse-jee-juno-SR2-linux-gtk-x86_64.tar.gz
mv eclipse eclipse-juno-sr2
tar -xf ~/Downloads/eclipse-jee-indigo-SR2-linux-gtk-x86_64.tar.gz
mv eclipse eclipse-indigo-sr2
ln -s eclipse-indigo-sr2 eclipse

install eclim

java -jar ~/Downloads/eclim_1.7.13.jar

java -jar ~/Downloads/eclim_2.2.5.jar

eclipse

1.7.2 Other emacs related support tools

sudo apt-get install \
             exuberant-ctags

1.8 XMonad

I use the super awsome xmonad window manager.

1.8.1 XMonad preparations

The following packages must not be installed since they will conflict with a custom built xmonad libraries.

sudo apt-get remove \
             xmonad \
             libghc6-xmonad-dev \
             libghc6-xmonad-contrib-dev

These packages are required for building XMonad.

sudo apt-get install \
             libxft-dev \
             libxinerama-dev \
             libxrandr-dev

Enable xmonad selection in lightdm:

Create a new file /usesr/share/xsessions/custom.desktop with:

[Desktop Entry]
Name=Xsession
Exec=/etc/X11/Xsession

1.8.2 XMonad Installation

I have created a script that checks out the latest XMonad and XMonadContrib repositories, apply patches and builds XMonad.

Run xmonad installation script

~/.bin-xmonad/xmonadUpdate
1.8.2.1 Troubleshooting

If multi-head setup does not work, you have forgot to install libxinerama development headers. See the XMonad FAQ for details.

1.8.3 The rest of the desktop dependencies

xmobar

sudo apt-get install libiw-dev
cabal install xmobar --flags="with_mpd with_utf8 with_xft with_iwlib with_datezone"

My XMonad configuration depends on the following packages as well.

sudo apt-get install \
             suckless-tools \
             gmrun \
             xbindkeys\
             x11-xserver-utils\
             xsel \
             scrot \
             pavucontrol \
             trayer \
             dzen2 \
             conky \
             xdotool \
             pinentry-gtk2 \
             gnupg-agent \
             rxvt-unicode-256color \
             xfonts-terminus \
             xfonts-terminus-dos \
             xfonts-terminus-oblique \
             lightgdm \
             xcalib \
             wmctrl \
             arandr

Yeganesh

cabal install yeganesh

Install rest of gnome as well (Don't do this on low end sytems)

sudo apt-get install \
             gnome \
             light-themes

Set rxvt as the default terminal emulator

sudo update-alternatives --set x-terminal-emulator /usr/bin/urxvt

2 Other configurations

2.1 Add user to sudo/syslog/… additional groups

sudo usermod -a -G sudo a00001
sudo usermod -a -G adm a00001
sudo usermod -a -G docker a00001

2.2 Set graphical greeter

sudo dpkg-reconfigure lightdm

2.3 Passwordless sudo

On all systems I usually disable password authentication for at least apt package upgrades. Launch sudoers configuration editing with sudo visudo and add the following to the bottom of the file:

# Allow passwordless apt updates and upgrades for admin users
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get update
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get upgrade
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get dist-upgrade
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get clean

Also, on desktop systems I usually allow rebooting and shutting down the system without a password

# Allow passwordless shutdown and reboot
%sudo,%admin ALL=(ALL)NOPASSWD:/sbin/shutdown now -h
%sudo,%admin ALL=(ALL)NOPASSWD:/sbin/reboot
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/sbin/pm-suspend
%sudo,%admin ALL=(ALL)NOPASSWD:/usr/sbin/pm-hibernate

Might need this on a mac

%sudo,%admin ALL=(ALL)NOPASSWD:/usr/local/bin/acdcontrol /dev/usb/hiddev*

2.4 Remove reserved file system blocks

By default 5% of a filesystem will be flagged as reserved for root user. For modern high-capacity disks, this is much higher than necessary - particularly if the partition is not being used for system files. It is generally safe to reduce the percentage of reserved blocks to free up disk space when the partition is either large or not being used for system files Use the tune2fs utility to do this. The command below would set the percentage of reserved blocks on the partition /dev/sdXY to 0.2%:

sudo tune2fs -m 0.2 /dev/sdXY

2.5 TODO Install roms for Vice Commodore emulator

# Install vice
sudo apt-get install vice

# Create temporary directory
cd `mktemp -d`

# Download CXXX roms and expand archive
wget ftp://ftp.zimmers.net/pub/cbm/crossplatform/emulators/VICE/old/vice-1.5-roms.tar.gz
tar -xf vice-1.5-roms.tar.gz

# Copy roms to correct location
cd vice-1.5-roms/data
sudo chown -R root:root .
sudo chmod -R 775 .
sudo rsync -r . /usr/lib/vice/

2.6 Create sftp-only user accounts

2.6.1 Set a user account, keys and permissions

Become super user

sudo -s

Set the username that will be created

new_user=foouser && new_user_home=/home/${new_user}

Make sure that suitable user groupe exists

addgroup sftponly

Create the user account

useradd -d ${new_user_home} -s /usr/lib/sftp-server -M -N -g sftponly ${new_user}

Create user home directories

mkdir -p ${new_user_home}/uploads /home/${new_user}/.ssh
chown ${new_user}:sftponly ${new_user_home}/uploads ${new_user_home}/.ssh
chmod 700 ${new_user_home}/.ssh

Add one or more keys to the new user account

cat ~/.ssh/id_rsa.pub >> ${new_user_home}/.ssh/authorized_keys

Set permissions of autorizedkeys

chmod 700 ${new_user_home}/.ssh/authorized_keys

Set ownership of authorizedkeys

chown ${new_user}:sftponly ${new_user_home}/.ssh/authorized_keys

2.6.2 Make sure sshd is set up correctly

Open /etc/shells and make sure that the following line exists

/usr/lib/sftp-server

Open the SSH server configuration file as root to start making changes. On a Ubuntu system, this file is usually /etc/ssh/sshdconfig This may differ with other distributions, so check beforehand.

Find the line Subsystem sftp /usr/lib/openssh/sftp-server and change it to read:

Subsystem sftp internal-sftp

Now add the following lines at the bottom of the file:

Match group sftponly
    ChrootDirectory %h
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp

The line Match group sftponly tells the SSH server to apply the configuration options below it to all members of the ‘sftponly‘ system group.

The line (ChrootDirectory %h tells the SSH server to confine a user to their home directory only (The home directory is specified here using ‘%h‘)

The ‘X11Forwarding no‘ and ‘AllowTcpForwarding no‘ lines prevent the user from, respectively, accessing graphical applications on the server and from connecting to other systems via ours.

The ‘ForceCommand internal-sftp ‘ line prevents the user from executing their own commands and forces them to use the SFTP server component of the SSH server by executing the ‘internal-sftp‘ command when the user logs in.

And restart the sshd daemon

sudo service restart ssh

2.7 Getting that znc/weechat/bitlbee combo to a server near you

2.7.1 ZNC (from source)

Ensure build dependencies are installed

sudo apt-get install \
             znc-dev \
             python3-dev \
             swig2.0 \
             libsasl2-dev \
             checkinstall

Check out the source

git clone https://github.com/znc/znc && cd znc

Autoconf (ZNC has a script for this)

./autogen.sh

Configure

./configure --enable-extra -enable-python --enable-sasl

Make

make

Install

sudo make insstall

2.7.2 TODO Create system service (using upstart)

THIS DOES NOT work…

http://wiki.znc.in/Running_ZNC_as_a_system_daemon

Create a system user for ZNC

adduser --system --home /var/lib/znc --group znc

Create ZNC default configuration

sudo -u znc /usr/local/bin/znc --chuid znc -- --datadir=/var/lib/znc --makeconf

Create a filed name /etc/init/znc.conf and fill it with the following contents

description "ZNC IRC bouncer"
author "Thomas Frössman <thomasf@jossystem.sem"

start on runlevel [2345]
stop on runlevel [016]

respawn

exec su - znc -c 'znc --foreground >> /var/log/znc.log 2>&1'

2.7.3 TODO Bitlbee (from maintainers packages)

2.7.4 TODO Weechat (from maintainers packages)

Get all .deb for stable @ http://www.weechat.org/download/stable/

An example might be everything from http://www.weechat.org/files/ubuntu/precise/0.3.8/i386/

Then install:

sudo dpkg -i *.deb

2.8 Set alternative DNS servers

Using google public dns as an example here:

2.8.1 If not using with DHCP

Edit resolv.conf

sudo emacs /etc/resolv.conf

For IPv4:

nameserver 8.8.8.8
nameserver 8.8.4.4

For IPv6:

nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844

2.8.2 with DHCP

edit /etc/resolvconf/resolv.conf.d/head and add these lines at the bottom. Don't forget to keep a newline at the end

nameserver 8.8.8.8
nameserver 8.8.4.4

2.9 TODO Etherpad lite service setup

The structure of /opt/etherpad-lite is something like this:

.
|-- etherpad-lite
|   |-- available_plugins
|   |-- bin
|   |-- doc
|   |-- node_modules
|   |-- out
|   |-- src
|   |-- static
|   |-- tools
|   |-- var
|   |-- APIKEY.txt
|   |-- CHANGELOG.md
|   |-- CONTRIBUTING.md
|   |-- LICENSE
|   |-- Makefile
|   |-- README.md
|   |-- README.plugins
|   |-- settings.json
|   |-- settings.json.template
|   `-- start.bat
|-- node -> node-v0.8.14-linux-x86
`-- node-v0.8.14-linux-x86
    |-- bin
    |-- include
    |-- lib
    |-- share
    |-- ChangeLog
    |-- LICENSE
    `-- README.md

Create a system user for etherpad-lite

adduser --system --home /opt/etherpad-lite --group etherpad-lite

Create a filed name /etc/init/etherpad-lite.conf and fill it with the following contents

description "etherpad-lite"

start on started networking
stop on runlevel [!2345]

env NODEHOME=/opt/etherpad-lite/node
env EPHOME=/opt/etherpad-lite/etherpad-lite
env EPLOGS=/var/log/etherpad-lite
env EPUSER=etherpad-lite

respawn

# pre-start script
#     chdir $EPHOME
#     mkdir $EPLOGS                              ||true
#     chown $EPUSER:admin $EPLOGS                ||true
#     chmod 0755 $EPLOGS                         ||true
#     chown -R $EPUSER:admin $EPHOME/var         ||true
#     $EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; }
# end script

script
  cd $EPHOME/
  exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- $NODEHOME/bin/node src/node/server.js \
                        >> $EPLOGS/access.log \
                        2>> $EPLOGS/error.log
end script

2.10 Make function keys default on apple keyboard

This hid-apple driver has options for this.

  • 0 = Fn key disabled
  • 1 = Fn key pressed by default
  • 2 = Fn key released by default

From /drivers/hid/hid-apple.c line 42:

Apply directly

echo 2 > /sys/module/hid_apple/parameters/fnmode

Making the modification persistent

Open or create the hidapple configuration file

sudo emacs /etc/modprobe.d/hid_apple.conf

Add this line

options hid_apple fnmode=2

Save file, apply changes and reboot

sudo update-initramfs -u

2.11 Disable crda wireless world regulatory domain

Just comment out everything in file://sudo:root@localhost:/lib/udev/rules.d/85-regulatory.rules

Manpage for crda

example syslog

wpa_supplicant[1108]: eth1: CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=0
kernel: [  162.659662] cfg80211: Calling CRDA to update world regulatory domain
NetworkManager[959]: <info> (eth1): supplicant interface state: completed -> disconnected
kernel: [  162.664195] cfg80211: World regulatory domain updated:
kernel: [  162.664200] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
kernel: [  162.664202] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
kernel: [  162.664203] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
kernel: [  162.664205] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
kernel: [  162.664206] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
kernel: [  162.664207] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
NetworkManager[959]: <info> (eth1): supplicant interface state: disconnected -> scanning
wpa_supplicant[1108]: eth1: Trying to associate with 00:00:00:00:00:00 (SSID='data' freq=2452 MHz)
NetworkManager[959]: <info> (eth1): supplicant interface state: scanning -> associating
wpa_supplicant[1108]: eth1: Associated with 00:00:00:00:00:00

2.12 TODO samba

sudo apt-get install samba

2.13 TODO mu4e osx

brew update
brew uninstall automake autoconf libtool pkg-config mu
brew install automake autoconf libtool pkg-config
EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs brew install mu --with-emacs --HEAD
brew install offlineimap

Copy the certificate into osx (apple stores theme in their keyring which python does not use).

On a ubuntu box or similar:

scp /etc/ssl/certs/ca-certificates.crt remoteOsXhost:

on the osx box:

sudo mkdir -p /etc/ssl/certs/
sudo mv ~/ca-certificates.crt /etc/ssl/certs/
sudo chmod 775 /etc/ssl/certs/ca-certificates.crt

# try it
offineimap --dry-run

3 Ubuntu upgrade notes

3.1 Ubuntu 13.04 to 13.10 upgrade

  • pomme turns off the display when the charger is disconnected, uninstalling pomme makes this go away

3.2 Ubuntu 13.10 to 14.04

Somehow docker got backgraded to 0.7 on one out of two machines upgraded.

reinstall docker

sudo apt-get remove lxc-docker
sudo apt-get install linux-image-extra-`uname -r`
curl -sSL https://get.docker.com/ | sh

Needed to uninstall redis-tool before redis stable ppa can be installed

sudo apt-get remove redis-server redis-tools

The Additional package repositories section of this manual is updated to reflect 14.10 changes.

Rvm seems to be incompatible with current 14.04 bash so let's delete rvm:

rm -rf ~/.rvm

install ruby 2.0 from apt instead (for now)

sudo apt-get install ruby2.1 ruby2.1-doc ruby2.1-dev

Reinstalled chrome to make it to readd its apt repository.

4 Ubuntu/debian bugs w. hotfixes

4.1 In rare occations, with certain router hardware (?) ssh times out when logging In

Edit $HOME.ssh/config and add this in the Host * stanza or for the host you have problems connecting to:

(TODO :unverified:)

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
MACs hmac-md5,hmac-sha1,hmac-ripemd160

or maybe, if nothing else works:

Ciphers 3des-cbc

4.2 Fix scenario when /boot is full and apt-get upgrade will not work

First find out which kernel you should NOT delete:

uname -r
3.8.0-35-generic

List all installed kernels

dpkg --list | grep linux-image
rc  linux-image-3.2.0-32-generic       3.2.0-32.51                       Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-30-generic       3.8.0-30.44~precise1              Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-34-generic       3.8.0-34.49~precise1              Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-35-generic       3.8.0-35.52~precise1              Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-36-generic       3.8.0-36.52~precise1              Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-37-generic       3.8.0-37.53~precise1              Linux kernel image for version 3.8.0 on 64 bit x86 SMP
iU  linux-image-generic-lts-raring     3.8.0.38.38                       Generic Linux kernel image

Delete the ones that will not be useful after an upgrate (keep the current one!)

sudo dpkg --purge linux-image-3.8.0-{30,34,36,37}

Then try to continue apt

sudo apt-get -f install

If that fails you probably have to install the kernel image that apt lists as an uninstalled dependency.

sudo apt-get install -f  linux-image-3.8.0-38-generic

Regenerate the grub boot menu here, just to feel safer.

sudo update-grub2

now apt should be able to continue

sudo apt-get -f install
sudo apt-get update
sudo apt-get upgrade

5 TODO Windows

A very small step by step what I always should install on a windows system..

I normally only uses windows in a virtualized envoronment to test development tool compatibility or in the rare occation where cross platform development cannot be used.

Install this

  1. git
  2. msys
  3. cygwin
  4. emacs

6 Installing an OSX

6.1 docker (vmware fusion)

curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine
curl -L https://get.docker.com/builds/Darwin/x86_64/docker-latest > /usr/local/bin/docker
chmod +x /usr/local/bin/docker
chmod +x /usr/local/bin/docker-machine
docker-machine  create \
                -d vmwarefusion \
                --vmwarefusion-memory-size "2048"  \
                --vmwarefusion-boot2docker-url "https://github.com/boot2docker/boot2docker/releases/download/v1.6.2/boot2docker.iso" \
                docker
eval "$(docker-machine env docker)"

6.2 Setting up the system default python

sudo easy_install pip
sudo pip install virtualenvwrapper

6.3 install homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

6.4 Application installs

most stuff that should be installed by cask/brew

The prerequisite is to have at least xcode/osx command line tools installed.

basic stuff:

brew install bash bash-completion git mercurial ispell 
brew install go nodejs 
brew install flac imagemagick 
brew install mosh htop-osx

extended stuff:

brew install kdiff3
brew tap benswift/extempore
brew install extempore

cask and casks:

brew install caskroom/cask/brew-cask

brew cask install \
          calibre gpgtools transmission \
          emacs intel-power-gadget steam \
          vlc firefox iterm2 xquartz google-chrome \
          karabiner cyberduck keka dropbox

brew cask install \
          xquartz google-chrome karabiner \
          cyberduck keka dropbox

7 Snippets and stuff for quickly doing things that are seldom done

7.1 vagrant osx install

#+beginexample. vagrant plugin install vagrant-vmware-fusion vagrant plugin install vagrant-vmware-fusion

#+endexample

7.2 samba

7.2.1 setup user owned shares

add/set password for smb user

sudo smbpasswd -a <username>

add share to file://sudo:root@localhost:/etc/samba/smb.conf

[icy]
path = /media/icy
available = yes
valid users = a00001
read only = no
browseable = yes
public = yes
writable = yes
hide dot files = no

7.2.2 public shares

To skip having to deal with subtle strangeness between windows/samba.. Let's use a specific guest accont.

Create user

sudo useradd -c "x" -d /dev/null -s /bin/false x

Set smb password:

sudo smbpasswd -a x

open file://sudo:root@localhost:/etc/samba/smb.conf

Add share(s):

[music]
path = /media/icy/Music
read only = yes
valid users = x
browseable = yes
writable = no
hide dot files = no

[video]
path = /media/icy/Video
read only = yes
valid users = x
browseable = yes
writable = no
hide dot files = no

[installables]
path = /media/icy/installables
read only = yes
valid users = x
browseable = yes
writable = no
hide dot files = no

7.3 docker cleanup

remove unnamed images (not very safe, "grep none" could match something to be kept)

docker images --no-trunc | grep none | awk '{print $3}' | xargs -r docker rmi

Remove Docker containers with Exit status

docker ps -a --no-trunc | grep 'Exit' | awk '{print $1}' | xargs -r docker rm

Author: Thomas Frössman

Created: 2015-09-01 tis 21:13

Validate