forked from 0k/0k-charms
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
3.2 KiB
191 lines
3.2 KiB
#!/bin/bash
|
|
|
|
set -eux # -x for verbose logging to juju debug-log
|
|
|
|
DOCKER=${DOCKER:-}
|
|
|
|
## 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:-""}
|
|
|
|
|
|
|
|
apt-get -y install bash-completion wget bzip2 git-core less language-pack-en python-software-properties tmux sudo git
|
|
|
|
|
|
|
|
##
|
|
## Allows to mount nfs shares
|
|
##
|
|
|
|
## XXXvlab: interracts really badly with current chroot mode. Leaving
|
|
## daemonized process reparented to PID 1 that prevents umounting and
|
|
## finally making the script failing, and then lxc-create launch a lxc-destroy
|
|
## triggering a 'rm -rf' upon '/dev'...
|
|
#test "$(lsb_release -c -s)" == "precise" && apt-get -y install nfs-common
|
|
|
|
##
|
|
## etckeeper
|
|
##
|
|
|
|
if [ -z "$DOCKER" ]; then
|
|
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
|
|
|
|
git config --system user.email "default@$(hostname)"
|
|
git config --system user.name "default"
|
|
|
|
|
|
etckeeper init
|
|
fi
|
|
|
|
##
|
|
## Git utilities
|
|
##
|
|
|
|
cat <<EOF > /etc/gitconfig
|
|
[alias]
|
|
co = checkout
|
|
com = commit
|
|
st = status
|
|
ci = commit
|
|
|
|
[color]
|
|
branch = auto
|
|
diff = auto
|
|
interactive = auto
|
|
status = auto
|
|
|
|
[core]
|
|
whitespace = fix
|
|
excludesfile = /etc/gitignore
|
|
|
|
EOF
|
|
|
|
cat <<EOF > /etc/gitignore
|
|
docs/build/*
|
|
develop-eggs/*
|
|
*.pyc
|
|
*.o
|
|
.installed.cfg
|
|
eggs/*
|
|
*.egg-info/*
|
|
*.orig
|
|
dist/*
|
|
build/*
|
|
buildout.dev.cfg
|
|
*~
|
|
*#
|
|
.#*
|
|
*.swp
|
|
*_flymake.*
|
|
.svn
|
|
|
|
EOF
|
|
|
|
##
|
|
## ldap client
|
|
##
|
|
|
|
#?
|
|
|
|
|
|
|
|
##
|
|
## 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
|
|
|
|
|
|
##
|
|
## ssh config
|
|
##
|
|
|
|
|
|
cp src/etc/ssh/lxc_git_access_id_rsa /etc/ssh/lxc_git_access_id_rsa
|
|
chmod 0600 /etc/ssh/lxc_git_access_id_rsa
|
|
|
|
mkdir -p /root/.ssh
|
|
|
|
cat <<EOF > /root/.ssh/config
|
|
|
|
Host git.0k.io
|
|
User lxc-user
|
|
IdentityFile /etc/ssh/lxc_git_access_id_rsa
|
|
UserKnownHostsFile /dev/null
|
|
StrictHostKeyChecking no
|
|
Port 10022
|
|
|
|
EOF
|
|
|
|
|
|
##
|
|
## install git sub
|
|
##
|
|
|
|
|
|
(
|
|
mkdir -p /opt/apps &&
|
|
cd /opt/apps &&
|
|
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/git-sub &&
|
|
ln -sf /opt/apps/git-sub/bin/git-sub /usr/lib/git-core/
|
|
)
|