fork 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

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. cat <<EOF >> /etc/apt/sources.list
  73. ## vlab's shell libraries
  74. deb http://deb.kalysto.org no-dist kal-alpha kal-beta kal-main
  75. EOF
  76. ##
  77. ## More shell configurations (prompt, functions)
  78. ##
  79. mkdir -p /etc/prompt
  80. cat <<EOF > /etc/prompt/prompt.1.rc
  81. PROMPT_COMMAND=""
  82. parse_git_branch() {
  83. ref=\$(git symbolic-ref HEAD 2> /dev/null) || return
  84. echo -en ' (\033[0;32m'\${ref#refs/heads/}'\033[0m)'
  85. }
  86. 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\]"
  87. EOF
  88. cat <<EOF >> /root/.bashrc
  89. ## History management
  90. export HISTCONTROL=ignoredups
  91. export HISTSIZE=50000
  92. shopt -s histappend
  93. PROMPT_COMMAND='history -a'
  94. ## Prompt easy management
  95. prompt() {
  96. prompt_name="prompt.\$1.rc"
  97. for i in /etc/prompt ~/.prompt; do
  98. [ -f "\$i/\$prompt_name" ] &&
  99. . "\$i/\$prompt_name"
  100. done
  101. }
  102. ## Git log command
  103. function glog() {
  104. git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@"
  105. }
  106. prompt 1
  107. EOF
  108. ##
  109. ## ssh config
  110. ##
  111. cp src/etc/ssh/lxc_git_access_id_rsa /etc/ssh/lxc_git_access_id_rsa
  112. chmod 0600 /etc/ssh/lxc_git_access_id_rsa
  113. mkdir -p /root/.ssh
  114. cat <<EOF > /root/.ssh/config
  115. Host git.0k.io
  116. User lxc-user
  117. IdentityFile /etc/ssh/lxc_git_access_id_rsa
  118. UserKnownHostsFile /dev/null
  119. StrictHostKeyChecking no
  120. Port 10022
  121. EOF
  122. ##
  123. ## install git sub
  124. ##
  125. (
  126. mkdir -p /opt/apps &&
  127. cd /opt/apps &&
  128. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/git-sub &&
  129. ln -sf /opt/apps/git-sub/bin/git-sub /usr/lib/git-core/
  130. )