From: Penny Leach Date: Tue, 15 Apr 2008 02:53:10 +0000 (+1200) Subject: eduforge profile. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=44639660187d1b24f9000fd683a46c009cf35d65;p=vserverctl.git eduforge profile. --- diff --git a/profile/eduforge/aptsources b/profile/eduforge/aptsources new file mode 100644 index 0000000..106a2a4 --- /dev/null +++ b/profile/eduforge/aptsources @@ -0,0 +1,16 @@ +# Citylink Mirror +#deb http://ftp.nz.debian.org/debian/ sarge main non-free +#deb-src http://ftp.nz.debian.org/debian/ sarge main +deb http://debian.catalyst.net.nz/debian/ sarge main non-free +deb-src http://debian.catalyst.net.nz/debian/ sarge main + +# Catalyst Packages +deb http://debian.catalyst.net.nz/catalyst stable catalyst + +# Security Updates +deb http://security.debian.org/ sarge/updates main +deb-src http://security.debian.org/ sarge/updates main + +# To match manage.eduforge.org +deb http://www.backports.org/debian sarge-backports main contrib non-free +deb http://volatile.debian.net/debian-volatile sarge/volatile main contrib non-free diff --git a/profile/eduforge/data/.bashrc b/profile/eduforge/data/.bashrc new file mode 100644 index 0000000..78e253c --- /dev/null +++ b/profile/eduforge/data/.bashrc @@ -0,0 +1,60 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples +shopt -s histappend + +. /etc/bash_completion +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +export HISTCONTROL=ignoredups + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in +xterm-color) + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + ;; +*) + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' + ;; +esac + +[ -x ~/.sh_prompt ] && . ~/.sh_prompt + + +# enable color support of ls and also add handy aliases +if [ "$TERM" != "dumb" ]; then + eval "`dircolors -b`" + alias ls='ls --color=auto' + #alias dir='ls --color=auto --format=vertical' + #alias vdir='ls --color=auto --format=long' +fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +#if [ -f /etc/bash_completion ]; then +# . /etc/bash_completion +#fi + +[ -r ~/.sh_aliases ] && . ~/.sh_aliases +[ -r ~/.sh_env ] && . ~/.sh_env +[ -r ~/.sh_func ] && . ~/.sh_func diff --git a/profile/eduforge/data/.pgpass b/profile/eduforge/data/.pgpass new file mode 100644 index 0000000..66d5127 --- /dev/null +++ b/profile/eduforge/data/.pgpass @@ -0,0 +1 @@ +*:*:*:gforge:wahP8xoo diff --git a/profile/eduforge/data/.sh_aliases b/profile/eduforge/data/.sh_aliases new file mode 100755 index 0000000..ff4be64 --- /dev/null +++ b/profile/eduforge/data/.sh_aliases @@ -0,0 +1,35 @@ +alias ..='cd ..' +alias ...='cd ../..' +alias acs='apt-cache search' +alias agi='sudo aptitude install' +alias agu='sudo aptitude update' +alias cgd='cg-diff' +alias cgfixtags='cg-restore -f tags' +alias cgl='cg-log' +alias cgs='cg-status' +alias cp='cp -v' +alias df='df -h' +alias dotdirs='perl -e '\''$,="\n"; print grep { -d && /\.[^. ]+/ } <.*>; print "\n";'\''' +alias du='du -h' +alias florida='lftp sftp://luke@florida.wgtn.cat-it.co.nz' +alias gk2w='gitk --all --since=2.weeks.ago' +alias grep='egrep' +alias home='ssh -Xt 60.234.149.239' +alias la='ls -AXF --color=always' +alias ll='ls -lhXF --color=always' +alias lla='ll -hAXF --color=always' +alias ls='ls -XF --color=always' +alias mach='ssh mach.catalyst.net.nz' +alias mv='mv -v' +alias now='date +"%Y%m%d-%H%M%S"' +alias phtags='ctags --langmap=php:+.inc.html.class -R *' +alias rm='rm -v' +alias silence='sudo mount -t smbfs -o guest //silence/music /media/silence' +alias ~='cd ~' +alias kgd='GIT_EXTERNAL_DIFF=~/bin/fakediff cgd' +#alias ssh='bcvim --wrap-ssh --' +alias mdinfo='grep -e '\''^\$CFG->db'\'' config.php' +alias gs='git-status' +alias gl='git-log' +alias gd='git-diff' +alias gco='git-checkout' diff --git a/profile/eduforge/data/.sh_env b/profile/eduforge/data/.sh_env new file mode 100644 index 0000000..aa27f39 --- /dev/null +++ b/profile/eduforge/data/.sh_env @@ -0,0 +1,17 @@ +# git development env +export GIT_AUTHOR_NAME=Luke\ Hudson +export GIT_COMMITTER_NAME=Luke\ Hudson +export GIT_COMMITTER_EMAIL=luke@catalyst.net.nz +export GIT_AUTHOR_EMAIL=luke@catalyst.net.nz +export PATH=$PATH:~/bin:~/code/perl:~/code/perl/pgtools:~/code/perl/moodle + +export EDITOR=/usr/bin/vim +export KARMDIR=~/.kde/share/apps/karm + +export CVS_RSH=ssh + +export GITSSH='git+ssh://git.catalyst.net.nz/var/git' +export GITHTTP='http://git.catalyst.net.nz/git' + +export PAPERSIZE="a4" +export PAPERCONF="/etc/papersize" diff --git a/profile/eduforge/data/.sh_func b/profile/eduforge/data/.sh_func new file mode 100644 index 0000000..0d67a28 --- /dev/null +++ b/profile/eduforge/data/.sh_func @@ -0,0 +1,44 @@ +function sbackup() { + if [ $# -eq 0 ] + then + echo -e "Usage:\n\tbackup(file)" + return + fi + bkp="$1.`now`" + sudo cp -v "$1" "$bkp" +} + +function backup() { + if [ $# -eq 0 ] + then + echo -e "Usage:\n\tbackup(file)" + return + fi + bkp="$1.`now`" + cp -v "$1" "$bkp" +} + +function cgc() { + if [ $# -lt 2 ] + then + echo -e "Uasge:\n\tcgc gitfile#branch targetdir" + return + fi + branch=$1 + dir=$2 + # echo "cloning from $branch to $dir" + cg-clone "git+ssh://git.catalyst.net.nz/var/git/$branch" "$dir" +} + +function q() { + [ $# -eq 0 ] && echo "Usage: q command" && return + $* >/dev/null 2>&1 & +} + +function finame () { + find . -iname '*'"$1"'*' +} +function firegex() { + find . -regextype egrep -regex "$1" +} + diff --git a/profile/eduforge/data/.vimrc b/profile/eduforge/data/.vimrc new file mode 100644 index 0000000..f799738 --- /dev/null +++ b/profile/eduforge/data/.vimrc @@ -0,0 +1,166 @@ +set history:50 " keep 50 lines of command line history +set ruler " show the cursor position all the time +set incsearch " do incremental searching +set number " Line numbering +set mouse=a " Full mouse usage +" Tabstuff +set expandtab +set shiftwidth:4 +set tabstop:4 +set guifont:Bitstream\ Vera\ Sans\ Mono\ Bold\ 10 +set vb " Visual bell instead of annoying beeps +set shellcmdflag=-ic +set nowrapscan + +if !has("gui_running") + set bg=dark +else + colorscheme darkblue +endif + +syntax on + +" Only do this part when compiled with support for autocommands. +if has("autocmd") + " Enable file type detection. + " Use the default filetype settings, so that mail gets 'tw' set to 72, + " 'cindent' is on in C files, etc. + " Also load indent files, to automatically do language-dependent indenting. + filetype plugin indent on + + " Put these in an autocmd group, so that we can delete them easily. + augroup vimrcEx + au! + + " For all text files set 'textwidth' to 78 characters. + autocmd FileType text setlocal textwidth=78 + + " When editing a file, always jump to the last known cursor position. + " Don't do it when the position is invalid or when inside an event handler + " (happens when dropping a file on gvim). + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif + + augroup END +else + set autoindent " always set autoindenting on +endif " has("autocmd") + +" Don't use Ex mode, use Q for formatting +map Q gq + +" Movement mapping +imap  b +" Maps C-LEFT to back-word in insert mode and cmdline etc. +imap  w +" Maps C-RIGHT to fwd-word in insert mode and cmdline etc. +map  b +" Maps C-LEFT to back-word in normal mode +map  w +" Maps C-RIGHT to fwd-word in normal mode + +map  [5~ +" Ctrl+Up == PageUp +map  [6~ +" C+Down = PageDn +map  gg +" C+Home = go-begin +map  G +" C+End = go-end +imap  [5~ +" Ctrl+Up == PageUp +imap  [6~ +" C+Down = PageDn +imap  gg +" C+Home = go-begin +imap  G +" C+End = go-end + +" map F5 to save+execute current file +"map :w :execute '!clear;' . getcwd() . '/' . bufname('%') +"imap :w :execute '!clear;' . getcwd() . '/' . bufname('%') + +" Use F6 and C-F6 to move between files +"map :bn +"map [17;5~ :bp +"map! [17;5~ :bp +"map! :bn + +" Control+S saves, due to long habit +imap  :w +map  :w + +" F12 shows browser window +"map :call VE() +"imap :call VE() + +" F3 does what I expect (find next) +"cmap n +"map n + +" F10 shows list of sub's in current file +map :execute "grep sub ".bufname('%')^M^M:cw^M +" Alt+Insert toggles mouse on/off + +map [2;3~ :call ToggleMouse() +map! [2;3~ :call ToggleMouse() + +" Another long habit - Ctrl+Space for completion +imap  + + +"-------------------------------------------------------------------------------- +" Functions and commands +"-------------------------------------------------------------------------------- +" +command Rz :call Resolve() + +function VE() + let g:explVertical=1 + let g:explStartRight=1 + let g:explWinSize=45 + S + let g:explVertical=0 + let g:explStartRight=0 + let g:explWinSize=15 +endfu + +function ToggleMouse() + if &mouse=="a" + let &mouse="" + echo "Mouse disabled" + else + let &mouse="a" + echo "Mouse enabled" + endif +endfu + +function SplitSwitch() + let path=bufname("%") +endfu + +function Resolve() + let orig=substitute( bufname('%'), '.rej','','') + execute ':sp ' . orig + set ft:php +endfu + + +function Comment() + '<,'>s/^/#/ +endfu + + +set t_Co=88 + +"if has("terminfo") +" set t_Co=16 +" set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm +" set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm +"else +" set t_Co=16 +" set t_Sf=[3%dm +" set t_Sb=[4%dm +"endif diff --git a/profile/eduforge/data/eduforge.pgdump b/profile/eduforge/data/eduforge.pgdump new file mode 120000 index 0000000..4431876 --- /dev/null +++ b/profile/eduforge/data/eduforge.pgdump @@ -0,0 +1 @@ +/home/luke/eduforge.pgdump \ No newline at end of file diff --git a/profile/eduforge/data/eduforge_wiki.pgdump b/profile/eduforge/data/eduforge_wiki.pgdump new file mode 120000 index 0000000..6c7bbff --- /dev/null +++ b/profile/eduforge/data/eduforge_wiki.pgdump @@ -0,0 +1 @@ +/home/luke/eduforge_wiki.pgdump \ No newline at end of file diff --git a/profile/eduforge/data/fix1252 b/profile/eduforge/data/fix1252 new file mode 100755 index 0000000..f91ece5 Binary files /dev/null and b/profile/eduforge/data/fix1252 differ diff --git a/profile/eduforge/data/restoredb.sh b/profile/eduforge/data/restoredb.sh new file mode 100755 index 0000000..7143405 --- /dev/null +++ b/profile/eduforge/data/restoredb.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +cd /root +mkdir out +chmod a+rwX -R out +cd out +pg_restore -Ox ../eduforge.pgdump -f eduforge.sql +/root/fix1252 eduforge.sql eduforge_fixed.sql + +sudo -u postgres psql template1 -c "update pg_shadow set usesuper=true where usename='gforge'" + +psql -U gforge eduforge -f eduforge_fixed.sql 2>&1 > /root/eduforge_restore.log + +pg_restore -Ox -U gforge -d eduforge_wiki /root/eduforge_wiki.pgdump 2>&1 > /root/eduforge_wiki_restore.log + + +sudo -u postgres psql template1 -c "update pg_shadow set usesuper=false where usename='gforge'" diff --git a/profile/eduforge/files b/profile/eduforge/files new file mode 100644 index 0000000..4e075f2 --- /dev/null +++ b/profile/eduforge/files @@ -0,0 +1,5 @@ +eduforge.pgdump root +eduforge_wiki.pgdump root +fix1252 root +restoredb.sh root +.pgpass root diff --git a/profile/eduforge/options b/profile/eduforge/options new file mode 100644 index 0000000..27d7766 --- /dev/null +++ b/profile/eduforge/options @@ -0,0 +1 @@ +username diff --git a/profile/eduforge/packages b/profile/eduforge/packages new file mode 100644 index 0000000..6359835 --- /dev/null +++ b/profile/eduforge/packages @@ -0,0 +1,31 @@ +sudo +ssh +curl +locales +less +apache +libapache-dbi-perl +libapache-mod-choke +libapache-mod-perl +libapache-mod-ssl +libapache-mod-php4 +php4 +libphp-jpgraph +php4-cgi +php4-cli +php4-common +php4-domxml +php4-gd +php4-imagick +php4-ldap +php4-mcrypt +php4-mysql +php4-pear +php4-pgsql +php4-xslt +postgresql +postgresql-client +postgresql-contrib +cronolog +lsof + diff --git a/profile/eduforge/post-host b/profile/eduforge/post-host new file mode 100644 index 0000000..41f8f43 --- /dev/null +++ b/profile/eduforge/post-host @@ -0,0 +1,10 @@ +# Add a /etc/hosts entry on the HostOS +cat /etc/hosts > /etc/hosts.new +echo "${VSIPADDR} ${VSNAME}.$(hostname -f) ${VSNAME}" >> /etc/hosts.new +mv /etc/hosts.new /etc/hosts + +# Copy the user's password from the host +grep -v "^${PROFILEOPTION_username}" ${VSROOT}/etc/shadow > /vserver/.shadow +grep "^${PROFILEOPTION_username}" /etc/shadow >> /vserver/.shadow +mv /vserver/.shadow ${VSROOT}/etc/shadow + diff --git a/profile/eduforge/post-vserver b/profile/eduforge/post-vserver new file mode 100644 index 0000000..933f7df --- /dev/null +++ b/profile/eduforge/post-vserver @@ -0,0 +1,67 @@ +echo "${PROFILEOPTION_username} ALL=(ALL) ALL" >> /etc/sudoers +DEBIAN_PRIORITY=critical; dpkg-reconfigure locales + + + +# Setup links to eduforge src +ln -s /usr/share/eduforge/etc /etc/gforge +ln -s /usr/share/eduforge/etc/httpd.conf /etc/apache/conf.d/gforge.httpd.conf +ln -s /usr/share/eduforge /usr/lib/gforge + + +# Setup db user and pg_hba.conf, and empty databases +sudo -u postgres createuser -A -d gforge +sudo -u postgres createdb -E UTF8 -O gforge eduforge +sudo -u postgres createdb -E LATIN1 -O gforge eduforge_wiki + +# insert gforge user into pg_hba.conf, at line 91 (suits this version of file) +sed -ri '88s/.*/\0\nlocal all gforge md5\n/' /etc/postgresql/pg_hba.conf +/etc/init.d/postgresql restart + +# For command-line convenience +sudo -u postgres createuser -a -d root +sudo -u postgres createdb root -O root + +## In case tsearch2 needs adding -- shouldn't if doing pg_restore from eduforge db. +# #(cd /usr/share/postgresql/7.4/main/contrib; sudo -u postgres psql eduforge < tsearch2.sql) + +# Enable apache mods +apache-modconf apache enable mod_env +apache-modconf apache enable mod_vhost_alias +apache-modconf apache enable mod_ssl + +# Enable postgresql extension for php +sed -ri '539s/.*/\0\nextension=pgsql.so\n/' /etc/php4/apache/php.ini +sed -ri '539s/.*/\0\nextension=pgsql.so\n/' /etc/php4/cli/php.ini +/etc/init.d/apache restart + +# Add gforge nix user etc. +groupadd gforge +useradd -g gforge -m gforge + +mkdir /home/groups +mkdir /usr/share/eduforge/homedirs +ln -s /home/groups /usr/share/eduforge/homedirs/groups + +(cd /usr/share/eduforge; ./setup) + +updatedb + +(cd /root; ./restoredb.sh) +#pg_restore -Ox -U gforge -d eduforge /root/eduforge.pgdump 2>&1 >/root/eduforge_restore.log +#pg_restore -Ox -U gforge -d eduforge_wiki /root/eduforge_wiki.pgdump 2>&1 > /root/eduforge_wiki_restore.log + +/etc/init.d/apache restart + +# Now set the password for gforge dbuser. This isn't done earlier so that pg_restores work (I hope) +sudo -u postgres psql template1 -c "alter user gforge with encrypted password 'wahP8xoo';" + + +echo ' + +You will probably have to do the following manually inside the vserver. + +cd /root +./restoredb.sh + +' diff --git a/profile/eduforge/pre-host b/profile/eduforge/pre-host new file mode 100644 index 0000000..8cfea41 --- /dev/null +++ b/profile/eduforge/pre-host @@ -0,0 +1,22 @@ +mkdir /etc/vservers/${VSNAME}/scripts -p +mkdir /vserver/${VSNAME}/data -p + +echo '/home' > /etc/vservers/${VSNAME}/namespace-cleanup-skip + +if [ -d /home/${PROFILEOPTION_username}/src/${VSNAME}/ ]; then + cat >/etc/vservers/${VSNAME}/scripts/pre-start << EOF + #!/bin/bash + mkdir -p /vserver/${VSNAME}/usr/share/${VSNAME}/ + mount --bind /home/${PROFILEOPTION_username}/src/${VSNAME}/ /vserver/${VSNAME}/usr/share/${VSNAME}/ + +EOF + chmod 755 /etc/vservers/${VSNAME}/scripts/pre-start + + cat >/etc/vservers/${VSNAME}/scripts/post-stop << EOF + #!/bin/bash + + umount /vserver/${VSNAME}/usr/share/${VSNAME} +EOF + chmod 755 /etc/vservers/${VSNAME}/scripts/post-stop + +fi diff --git a/profile/eduforge/pre-vserver b/profile/eduforge/pre-vserver new file mode 100644 index 0000000..aeea058 --- /dev/null +++ b/profile/eduforge/pre-vserver @@ -0,0 +1,12 @@ +if [ "$VSRELEASE" = "sarge" ]; then + echo "running pwconv" + pwconv +fi +cp /usr/share/zoneinfo/NZ /etc/localtime +echo "${VSIPADDR} ${VSNAME}" >> /etc/hosts +echo 'locales locales/locales_to_be_generated select en_NZ ISO-8859-1, en_NZ.UTF-8 UTF-8' | debconf-set-selections + + +echo 'debconf debconf/priority select critical' | debconf-set-selections +echo 'exim4-config exim4/dc_eximconfig_configtype string mail sent by smarthost; no local mail' | debconf-set-selections +echo 'exim4-config exim4/dc_smarthost string smtp.catalyst.net.nz' | debconf-set-selections diff --git a/profile/eduforge/profile.conf b/profile/eduforge/profile.conf new file mode 100644 index 0000000..f1cf346 --- /dev/null +++ b/profile/eduforge/profile.conf @@ -0,0 +1,11 @@ +parent = +release = sarge +mirror = http://debian.catalyst.net.nz/debian +inherit-aptsources = yes +inherit-packages = yes +inherit-pre-vserver = yes +inherit-pre-host = yes +inherit-post-vserver = yes +inherit-post-host = yes +inherit-files = yes +inherit-templates = yes diff --git a/profile/eduforge/remove-host b/profile/eduforge/remove-host new file mode 100644 index 0000000..590c832 --- /dev/null +++ b/profile/eduforge/remove-host @@ -0,0 +1,11 @@ +# Remove /etc/hosts entry on the host OS +grep -v "^${VSIPADDR}" /etc/hosts > /etc/hosts.new +mv /etc/hosts.new /etc/hosts + +# this isn't set because we don't pass options to remove +# USR=$PROFILEOPTION_username +USR=penny + +grep -v "^${VSNAME}" /home/${USR}/.ssh/known_hosts > /home/${USR}/.ssh/known_hosts.new +chown ${USR}:${USR} /home/${USR}/.ssh/known_hosts.new +mv /home/${USR}/.ssh/known_hosts.new /home/${USR}/.ssh/known_hosts