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.

197 lines
3.5 KiB

12 years ago
12 years ago
12 years ago
12 years ago
  1. #!/bin/bash
  2. set -eux # -x for verbose logging to juju debug-log
  3. DOCKER=${DOCKER:-}
  4. ## 0k git remote path
  5. GIT_0K_BASE=${GIT_0K_BASE:-"git.0k.io:/var/git"}
  6. ## 0k git remote options
  7. GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
  8. apt-get -y install bash-completion wget bzip2 git-core less python-software-properties tmux sudo git
  9. apt-get -y install language-pack-en || true ## Protect debian against failure here
  10. ##
  11. ## Allows to mount nfs shares
  12. ##
  13. ## XXXvlab: interracts really badly with current chroot mode. Leaving
  14. ## daemonized process reparented to PID 1 that prevents umounting and
  15. ## finally making the script failing, and then lxc-create launch a lxc-destroy
  16. ## triggering a 'rm -rf' upon '/dev'...
  17. #test "$(lsb_release -c -s)" == "precise" && apt-get -y install nfs-common
  18. ##
  19. ## etckeeper
  20. ##
  21. if [ -z "$DOCKER" ]; then
  22. apt-get install etckeeper
  23. sed -i 's/#VCS="git"/VCS="git"/g' /etc/etckeeper/etckeeper.conf
  24. sed -i 's/VCS="bzr"/#VCS="bzr"/g' /etc/etckeeper/etckeeper.conf
  25. git config --global user.email "default@$(hostname)"
  26. git config --global user.name "default"
  27. etckeeper init
  28. fi
  29. ##
  30. ## Git utilities
  31. ##
  32. cat <<EOF > /etc/gitconfig
  33. [alias]
  34. co = checkout
  35. com = commit
  36. st = status
  37. ci = commit
  38. [color]
  39. branch = auto
  40. diff = auto
  41. interactive = auto
  42. status = auto
  43. [core]
  44. whitespace = fix
  45. excludesfile = /etc/gitignore
  46. EOF
  47. cat <<EOF > /etc/gitignore
  48. docs/build/*
  49. develop-eggs/*
  50. *.pyc
  51. *.o
  52. .installed.cfg
  53. eggs/*
  54. *.egg-info/*
  55. *.orig
  56. dist/*
  57. build/*
  58. buildout.dev.cfg
  59. *~
  60. *#
  61. .#*
  62. *.swp
  63. *_flymake.*
  64. .svn
  65. EOF
  66. ##
  67. ## ldap client
  68. ##
  69. #?
  70. ##
  71. ## kal-scripts
  72. ##
  73. ##
  74. ## kal-scripts
  75. ##
  76. if ! [ -e /etc/apt/sources.list.d/kalysto.org.list ]; then
  77. cat <<EOF > /etc/apt/sources.list.d/kalysto.org.list
  78. ## vlab's shell libraries
  79. deb http://deb.kalysto.org no-dist kal-alpha kal-beta kal-main
  80. EOF
  81. ## Update only this repo:
  82. apt-get update -o Dir::Etc::sourcelist="sources.list.d/kalysto.org.list" \
  83. -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
  84. fi
  85. ##
  86. ## More shell configurations (prompt, functions)
  87. ##
  88. mkdir -p /etc/prompt
  89. cat <<EOF > /etc/prompt/prompt.1.rc
  90. PROMPT_COMMAND=""
  91. parse_git_branch() {
  92. ref=\$(git symbolic-ref HEAD 2> /dev/null) || return
  93. echo -en ' (\033[0;32m'\${ref#refs/heads/}'\033[0m)'
  94. }
  95. 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\]"
  96. EOF
  97. cat <<EOF >> /root/.bashrc
  98. ## History management
  99. export HISTCONTROL=ignoredups
  100. export HISTSIZE=50000
  101. shopt -s histappend
  102. PROMPT_COMMAND='history -a'
  103. ## Prompt easy management
  104. prompt() {
  105. prompt_name="prompt.\$1.rc"
  106. for i in /etc/prompt ~/.prompt; do
  107. [ -f "\$i/\$prompt_name" ] &&
  108. . "\$i/\$prompt_name"
  109. done
  110. }
  111. ## Git log command
  112. function glog() {
  113. git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@"
  114. }
  115. prompt 1
  116. EOF
  117. ##
  118. ## ssh config
  119. ##
  120. cp src/etc/ssh/lxc_git_access_id_rsa /etc/ssh/lxc_git_access_id_rsa
  121. chmod 0600 /etc/ssh/lxc_git_access_id_rsa
  122. mkdir -p /root/.ssh
  123. cat <<EOF > /root/.ssh/config
  124. Host git.0k.io
  125. User lxc-user
  126. IdentityFile /etc/ssh/lxc_git_access_id_rsa
  127. UserKnownHostsFile /dev/null
  128. StrictHostKeyChecking no
  129. Port 10022
  130. EOF
  131. ##
  132. ## install git sub
  133. ##
  134. (
  135. mkdir -p /opt/apps &&
  136. cd /opt/apps &&
  137. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/git-sub &&
  138. ln -sf /opt/apps/git-sub/bin/git-sub /usr/lib/git-core/
  139. )