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.

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