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.

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