Valentin Lab
11 years ago
2 changed files with 281 additions and 0 deletions
@ -0,0 +1,242 @@ |
|||
#!/bin/bash |
|||
|
|||
set -eux # -x for verbose logging to juju debug-log |
|||
|
|||
apt-get update |
|||
apt-get -y install bash-completion wget bzip2 git-core less language-pack-en python-software-properties tmux mosh sudo git |
|||
|
|||
## 0k git remote path |
|||
GIT_0K_BASE=${GIT_0K_BASE:-"git.0k.io:/var/git"} |
|||
|
|||
## 0k git remote options |
|||
GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""} |
|||
|
|||
|
|||
|
|||
|
|||
## |
|||
## etckeeper |
|||
## |
|||
|
|||
apt-get install etckeeper |
|||
|
|||
sed -i 's/#VCS="git"/VCS="git"/g' /etc/etckeeper/etckeeper.conf |
|||
sed -i 's/VCS="bzr"/#VCS="bzr"/g' /etc/etckeeper/etckeeper.conf |
|||
|
|||
etckeeper init |
|||
|
|||
|
|||
## |
|||
## Git utilities |
|||
## |
|||
|
|||
echo "[alias] |
|||
co = checkout |
|||
com = commit |
|||
st = status |
|||
ci = commit |
|||
|
|||
[color] |
|||
branch = auto |
|||
diff = auto |
|||
interactive = auto |
|||
status = auto |
|||
|
|||
" >> /etc/gitconfig |
|||
|
|||
|
|||
|
|||
## |
|||
## kal-scripts |
|||
## |
|||
|
|||
cat <<EOF >> /etc/apt/sources.list |
|||
|
|||
## vlab's shell libraries |
|||
deb http://deb.kalysto.org no-dist kal-alpha kal-beta kal-main |
|||
|
|||
EOF |
|||
|
|||
|
|||
## |
|||
## More shell configurations (prompt, functions) |
|||
## |
|||
|
|||
mkdir -p /etc/prompt |
|||
|
|||
cat <<EOF > /etc/prompt/prompt.1.rc |
|||
PROMPT_COMMAND="" |
|||
parse_git_branch() { |
|||
ref=\$(git symbolic-ref HEAD 2> /dev/null) || return |
|||
echo -en ' (\033[0;32m'\${ref#refs/heads/}'\033[0m)' |
|||
} |
|||
export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\h\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]" |
|||
EOF |
|||
|
|||
cat <<EOF >> /root/.bashrc |
|||
|
|||
## History management |
|||
|
|||
export HISTCONTROL=ignoredups |
|||
export HISTSIZE=50000 |
|||
shopt -s histappend |
|||
PROMPT_COMMAND='history -a' |
|||
|
|||
|
|||
## Prompt easy management |
|||
|
|||
prompt() { |
|||
prompt_name="prompt.\$1.rc" |
|||
|
|||
for i in /etc/prompt ~/.prompt; do |
|||
[ -f "\$i/\$prompt_name" ] && |
|||
. "\$i/\$prompt_name" |
|||
done |
|||
} |
|||
|
|||
|
|||
## Git log command |
|||
|
|||
function glog() { |
|||
git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@" |
|||
} |
|||
|
|||
|
|||
prompt 1 |
|||
|
|||
EOF |
|||
|
|||
|
|||
|
|||
|
|||
apt-get install -y kal-scripts python-pip |
|||
pip install shyaml |
|||
|
|||
## |
|||
## btrfs install |
|||
## |
|||
|
|||
apt-get install btrfs-tools |
|||
|
|||
root=/mnt/btrfs-root |
|||
|
|||
#mkdir /mnt/btrfs-root -p |
|||
#mount /mnt/btrfs-root |
|||
|
|||
|
|||
btrfs subvolume create $root/var |
|||
mkdir $root/var/{lib,cache,backups} -p |
|||
for d in $root/var/{lib,cache,backups}; do |
|||
btrfs subvolume create $d/lxc |
|||
done |
|||
|
|||
for d in $root/srv/{,lxc-datastore{,/config,/data}}; do |
|||
btrfs subvolume create $d |
|||
done |
|||
|
|||
mkdir srv/lxc |
|||
|
|||
|
|||
cat <<EOF >> /etc/fstab |
|||
|
|||
## binds |
|||
|
|||
/mnt/btrfs-root/var/lib/lxc /var/lib/lxc none bind,defaults,auto 0 0 |
|||
/mnt/btrfs-root/var/cache/lxc /var/cache/lxc none bind,defaults,auto 0 0 |
|||
/mnt/btrfs-root/var/backups/lxc /var/backups/lxc none bind,defaults,auto 0 0 |
|||
/mnt/btrfs-root/srv/lxc-datastore /srv/lxc-datastore none bind,defaults,auto 0 0 |
|||
|
|||
|
|||
EOF |
|||
|
|||
mkdir -p /var/backups/lxc /srv/lxc-datastore |
|||
|
|||
## |
|||
## lxc tools |
|||
## |
|||
|
|||
apt-get install lxc |
|||
|
|||
## mount all |
|||
|
|||
mkdir -p /opt/apps |
|||
|
|||
## |
|||
## Install 0k-manage for the handy oe command |
|||
## |
|||
|
|||
( |
|||
if ! [ -d "/opt/apps/0k-manage" ]; then |
|||
cd /opt/apps && |
|||
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" && |
|||
cd /opt/apps/0k-manage && |
|||
git checkout 0k/dev/master |
|||
fi |
|||
) |
|||
|
|||
## |
|||
## Install 0k-charms |
|||
## |
|||
|
|||
( |
|||
if ! [ -d "/opt/apps/0k-charms" ]; then |
|||
cd /opt/apps && |
|||
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-charms.git" && |
|||
cd /opt/apps/0k-manage && |
|||
git checkout 0k/dev/master |
|||
fi |
|||
) |
|||
|
|||
|
|||
## |
|||
## Install lxc-scripts |
|||
## |
|||
|
|||
( |
|||
if ! [ -d "/opt/apps/lxc-scripts" ]; then |
|||
cd /opt/apps && |
|||
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/lxc-scripts.git" && |
|||
cd /opt/apps/0k-manage && |
|||
git checkout master && |
|||
ln -sf /opt/apps/lxc-scripts/bin/lxc-* /usr/local/sbin/ && |
|||
ln -sf /opt/apps/lxc-scripts/usr/lib/lxc/templates/lxc-0k-ubuntu-cloud /usr/lib/lxc/templates/ |
|||
fi |
|||
) |
|||
|
|||
## |
|||
## Patch some files |
|||
## |
|||
|
|||
( |
|||
cd /etc && |
|||
cat /opt/apps/lxc-scripts/precise-12.04.patch | patch -p1 |
|||
|
|||
) |
|||
|
|||
## |
|||
## Install dns waterfall |
|||
## |
|||
|
|||
apt-get install -y bind9 dnsmasq |
|||
|
|||
|
|||
# edit /etc/dnsmaq.conf |
|||
echo " |
|||
server=$(. /etc/default/lxc && echo "$LXC_ADDR") |
|||
interface=lo |
|||
no-negcache |
|||
log-queries |
|||
log-facility=/var/log/dnsmasq.log |
|||
" >> /etc/dnsmasq.conf |
|||
|
|||
( |
|||
cd /etc && |
|||
cat src/bind9.patch | patch -p1 && |
|||
sed -ri s/%%EXTERNAL_IP%%/$(. /etc/default/lxc && ifip "$HOST_EXTERNAL_DEVICE") |
|||
) |
|||
mkdir /var/log/named -p && |
|||
chown bind:bind /var/log/named |
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,39 @@ |
|||
diff --git a/bind/named.conf.options b/bind/named.conf.options
|
|||
index 5b1981d..c1fd78c 100644
|
|||
--- a/bind/named.conf.options
|
|||
+++ b/bind/named.conf.options
|
|||
@@ -21,8 +21,32 @@ options {
|
|||
dnssec-validation auto; |
|||
|
|||
auth-nxdomain no; # conform to RFC1035 |
|||
- listen-on-v6 { ::1; };
|
|||
- listen-on { 127.0.0.1; };
|
|||
+ //listen-on-v6 { ::1; };
|
|||
+ listen-on { 178.33.122.174; };
|
|||
// allow-recursion { 127.0.0.1; }; |
|||
}; |
|||
|
|||
+
|
|||
+logging {
|
|||
+ channel warning
|
|||
+ {
|
|||
+ file "/var/log/named/dns.warnings.log";
|
|||
+ severity warning;
|
|||
+ print-category yes;
|
|||
+ print-severity yes;
|
|||
+ print-time yes;
|
|||
+ };
|
|||
+
|
|||
+ channel general_dns
|
|||
+ {
|
|||
+ file "/var/log/named/dns.log";
|
|||
+ severity info;
|
|||
+ print-category yes;
|
|||
+ print-severity yes;
|
|||
+ print-time yes;
|
|||
+ };
|
|||
+
|
|||
+ category default { warning; } ;
|
|||
+ category queries { general_dns; } ;
|
|||
+};
|
|||
+
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue