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.

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