Skip to content

Instantly share code, notes, and snippets.

@sgykfjsm
Last active September 12, 2015 22:53
Show Gist options
  • Save sgykfjsm/9e06eda66014177a883d to your computer and use it in GitHub Desktop.
Save sgykfjsm/9e06eda66014177a883d to your computer and use it in GitHub Desktop.
Install subversion-1.7.9
#!/usr/bin/env bash
set -eu
_OLDPWD=$(pwd)
test -d "${BASH_SOURCE[0]%/*}" && { cd "${BASH_SOURCE[0]%/*}" || exit 1; }
SCRIPT_DIR="$(pwd)"
SVN_URL=http://archive.apache.org/dist/subversion/subversion-1.7.9.tar.gz
SQLITE_URL=http://sqlite.org/sqlite-amalgamation-3071502.zip
REPOSITORY=/opt/svn/repository
rm -rf ${REPOSITORY} && mkdir -pv ${REPOSITORY}
deps() {
sudo yum install -y apr-util-devel sqlite-devel neon-devel openssl-devel mod_dav_svn httpd
sudo ln -sfv /usr/lib64/libapr-1.so /usr/lib64/libapr-1.a
}
download_source() {
if [ ! -f $(basename ${SVN_URL}) ]; then
wget --quiet ${SVN_URL}
fi
if [ ! -f $(basename ${SQLITE_URL}) ]; then
wget --quiet ${SQLITE_URL}
fi
wget --quiet ${SVN_URL}
wget --quiet ${SQLITE_URL}
rm -rf $(basename ${SVN_URL} .tar.gz) && tar zxf $(basename ${SVN_URL})
rm -rf $(basename ${SQLITE_URL} .zip) && unzip $(basename ${SQLITE_URL})
mv $(basename ${SQLITE_URL} .zip) $(basename ${SVN_URL} .tar.gz)/
}
install_subversion() {
local prefix_dir=/home/vagrant/apps/subversion-1.7.9
local libexec_dir=${prefix_dir}/libexec
local configure_opts="\
--prefix=${prefix_dir} \
--without-berkeley-db \
--enable-all-static \
--with-apache-libexecdir=${libexec_dir} \
--disable-mod-activation \
--without-apxs \
--without-swig \
--without-serf \
--without-ssl \
"
rm -rf ${prefix_dir} && mkdir -pv ${prefix_dir} ${libexec_dir}
cd ./subversion-1.7.9
./configure ${configure_opts}
make && make install
cd - > /dev/null
BASHRC=/home/vagrant/.bashrc
if ! grep -q subversion ${BASHRC} ; then
echo "export PATH=${prefix_dir}/bin:\${PATH}" >> ${BASHRC}
fi
chown -R vagrant:vagrant ${prefix_dir}
set +u
source ${BASHRC}
set -u
}
svn_setup() {
svnadmin create ${REPOSITORY}
local revprop=${REPOSITORY}/hooks/pre-revprop-change
cat <<EOF > ${revprop}
#!/bin/sh
exit 0
EOF
chmod +x ${revprop}
cd /tmp
if [ ! -d go-daemon ]; then
git clone https://github.com/sevlyar/go-daemon.git
fi
cd -
svn import /tmp/go-daemon file://${REPOSITORY}/go-daemon \
-m "import go-daemon"
}
httpd_setup(){
local httpd_svn_conf=/etc/httpd/conf.d/subversion.conf
if [ -f ${httpd_svn_conf} ]; then
cp -pv ${httpd_svn_conf} ${httpd_svn_conf}.$(date '+%Y%m%d%H%M%S.%Z')
fi
cat <<EOF > ${httpd_svn_conf}
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNPath ${REPOSITORY}
</Location>
EOF
chown -R apache:apache $(dirname ${REPOSITORY})
service iptables stop
service httpd start
chkconfig httpd on
}
main() {
deps
download_source
install_subversion
svn_setup
httpd_setup
}
main $@
[ -n "${_OLDPWD-}" ] && cd ${_OLDPWD}
exit
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment