witersen
3 years ago
27 changed files with 5104 additions and 122 deletions
@ -0,0 +1,341 @@
@@ -0,0 +1,341 @@
|
||||
<?php |
||||
/* |
||||
* @Author: witersen |
||||
* @Date: 2022-05-08 13:31:07 |
||||
* @LastEditors: witersen |
||||
* @LastEditTime: 2022-05-08 23:48:45 |
||||
* @Description: QQ:1801168257 |
||||
*/ |
||||
|
||||
/** |
||||
* 安装和升级程序 |
||||
*/ |
||||
|
||||
/** |
||||
* 将工作模式限制在cli模式 |
||||
*/ |
||||
if (!preg_match('/cli/i', php_sapi_name())) { |
||||
exit('require php-cli mode'); |
||||
} |
||||
|
||||
define('BASE_PATH', __DIR__); |
||||
|
||||
require_once BASE_PATH . '/../app/util/Config.php'; |
||||
|
||||
require_once BASE_PATH . '/../config/database.php'; |
||||
require_once BASE_PATH . '/../config/reg.php'; |
||||
require_once BASE_PATH . '/../config/svn.php'; |
||||
require_once BASE_PATH . '/../config/update.php'; |
||||
require_once BASE_PATH . '/../config/version.php'; |
||||
|
||||
require_once BASE_PATH . '/../app/function/curl.php'; |
||||
|
||||
class Install |
||||
{ |
||||
private $config_database; |
||||
private $config_reg; |
||||
private $config_svn; |
||||
private $config_update; |
||||
private $config_version; |
||||
|
||||
private $scripts = [ |
||||
[ |
||||
'index' => 1, |
||||
'note' => '帮我安装并配置Subversion' |
||||
], |
||||
[ |
||||
'index' => 2, |
||||
'note' => '按照本系统的要求初始化Subversion(针对以其它方式安装的Subversion)' |
||||
], |
||||
[ |
||||
'index' => 3, |
||||
'note' => '检测SVNAdmin的新版本' |
||||
], |
||||
]; |
||||
|
||||
function __construct() |
||||
{ |
||||
Config::load(BASE_PATH . '/../config/'); |
||||
|
||||
$this->config_database = Config::get('database'); |
||||
$this->config_reg = Config::get('reg'); |
||||
$this->config_svn = Config::get('svn'); |
||||
$this->config_update = Config::get('update'); |
||||
$this->config_version = Config::get('version'); |
||||
} |
||||
/** |
||||
* 检测SVNAdmin的新版本并选择更新 |
||||
*/ |
||||
function DetectUpdate() |
||||
{ |
||||
//拿到升级服务器配置信息 |
||||
//对升级服务器地址进行轮询 |
||||
//获取当前版本可升级的版本信息 |
||||
|
||||
foreach ($this->config_update['update_server'] as $value) { |
||||
//检测 |
||||
$versionInfo = FunCurlRequest($value); |
||||
//未超时 |
||||
if ($versionInfo != null) { |
||||
//json转换 |
||||
$versionInfo = json_decode($versionInfo, true); |
||||
$latestVersion = $versionInfo['latestVersion']; |
||||
if ($latestVersion == $this->config_version['version']) { |
||||
return message(200, 1, '当前版本为最新版'); |
||||
} else if ($latestVersion > $this->config_version['version']) { |
||||
return message(200, 1, '有更新', [ |
||||
'latestVersion' => $versionInfo['latestVersion'], |
||||
'fixedContent' => implode('<br>', $versionInfo['fixedContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['fixedContent']), |
||||
'newContent' => implode('<br>', $versionInfo['newContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['newContent']), |
||||
'updateType' => $versionInfo['updateType'], |
||||
'updateStep' => $versionInfo['updateStep'] |
||||
]); |
||||
} else if ($latestVersion < $this->config_version['version']) { |
||||
return message(200, 0, '系统版本错误'); |
||||
} |
||||
} |
||||
} |
||||
return message(200, 0, '检测更新超时'); |
||||
} |
||||
|
||||
/** |
||||
* 升级到指定版本的SVNAdmin |
||||
*/ |
||||
function UpdateSVNAdmin() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 将SVNAdmin加入到开机自启动 |
||||
*/ |
||||
function InitlSVNAdmin() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 将SVNAdmin取消开机自启动 |
||||
*/ |
||||
function UninitSVNAdmin() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 将SVNAdmin加入监控 如果检测到异常退出则自动重启 |
||||
*/ |
||||
function Monitor() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 卸载Subversion |
||||
*/ |
||||
function UninstallSubversion() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 获取当前安装的Subversion信息 |
||||
*/ |
||||
function DetectSubversion() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* 修改已经安装的Subversion配置以适合SVNAdmin的管理 |
||||
*/ |
||||
function ConfigSubversion() |
||||
{ |
||||
/** |
||||
* 1、检测Subversion的安装情况 |
||||
*/ |
||||
//检测是否有正在运行的进程 |
||||
$isRun = shell_exec('ps auxf|grep -v "grep"|grep svnserve') == '' ? false : true; |
||||
|
||||
//检测安装程序是否存在于环境变量 |
||||
$installPath = shell_exec('which svnserve'); |
||||
$isInstall = shell_exec('whereis svnserve') == 'svnserve:' ? false : true; |
||||
|
||||
//正在运行中但是没有安装或者subversion的相关程序没有被加入环境变量 |
||||
if ($isRun && !$isInstall) { |
||||
exit('需要将Subversion相关程序加入到环境变量后重试!' . PHP_EOL); |
||||
} |
||||
|
||||
//正在运行中并且subversion的相关程序已经被加入环境变量 |
||||
if ($isRun && $isInstall) { |
||||
//停止svnserve |
||||
exit('请先手动停止正在运行的svnserve程序后重试' . PHP_EOL); |
||||
} |
||||
|
||||
//不在运行中并且没有安装或者subversion的相关程序没有被加入环境变量 |
||||
if (!$isRun && !$isInstall) { |
||||
exit('需要安装Subversion或者需要将已安装的Subversion相关程序加入到环境变量后重试!' . PHP_EOL); |
||||
} |
||||
|
||||
//不在运行中并且subversion的相关程序已经被加入环境变量 |
||||
if (!$isRun && $isInstall) { |
||||
//相关文件配置 |
||||
} |
||||
|
||||
/** |
||||
* 相关文件配置 |
||||
*/ |
||||
$templete_path = BASE_PATH . '../templete/'; |
||||
|
||||
//创建SVNAdmin软件配置信息的主目录 |
||||
mkdir($this->config_svn['home_path'], 0700, true); |
||||
|
||||
//创建SVN仓库父目录 |
||||
mkdir($this->config_svn['rep_base_path'], 0700, true); |
||||
|
||||
//创建备份目录 |
||||
mkdir($this->config_svn['home_path'], 0700, true); |
||||
|
||||
//创建日志目录 |
||||
mkdir($this->config_svn['home_path'], 0700, true); |
||||
|
||||
//创建临时数据目录 |
||||
mkdir($this->config_svn['home_path'], 0700, true); |
||||
|
||||
//写入svnserve环境变量文件 |
||||
$con_svnserve_env_file = file_get_contents($templete_path . 'svnserve/svnserve'); |
||||
$con_svnserve_env_file = sprintf($con_svnserve_env_file, $this->config_svn['rep_base_path'], $this->config_svn['svn_conf_file'], $this->config_svn['svnserve_log_file']); |
||||
file_put_contents($this->config_svn['svnserve_env_file'], $con_svnserve_env_file); |
||||
|
||||
//写入SVN仓库权限配置文件 |
||||
$con_svn_conf_file = file_get_contents($templete_path . 'svnserve/svnserve.confg'); |
||||
file_put_contents($this->config_svn['svn_conf_file'], $con_svn_conf_file); |
||||
|
||||
//写入authz文件 |
||||
$con_svn_authz_file = file_get_contents($templete_path . 'svnserve/authz'); |
||||
file_put_contents($this->config_svn['svn_authz_file'], $con_svn_authz_file); |
||||
|
||||
//写入passwd文件 |
||||
$con_svn_passwd_file = file_get_contents($templete_path . 'svnserve/passwd'); |
||||
file_put_contents($this->config_svn['svn_passwd_file'], $con_svn_passwd_file); |
||||
|
||||
//创建svnserve运行日志文件 |
||||
file_put_contents($this->config_svn['svnserve_log_file'], ''); |
||||
|
||||
//创建pid文件 |
||||
file_put_contents($this->config_svn['svnserve_pid_file'], ''); |
||||
|
||||
/** |
||||
* 将svnserve注册为系统服务 |
||||
*/ |
||||
echo '===============================================' . PHP_EOL; |
||||
echo '清理之前注册的svnserve服务' . PHP_EOL; |
||||
|
||||
shell_exec('systemctl stop svnserve.service'); |
||||
shell_exec('systemctl disable svnserve.service'); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
$con_svnserve_service_file = file_get_contents($templete_path . 'svnserve/svnserve.service'); |
||||
$con_svnserve_service_file = sprintf($con_svnserve_service_file, $this->config_svn['svnserve_env_file'], trim($installPath), $this->config_svn['svnserve_pid_file']); |
||||
file_put_contents($this->config_svn['svnserve_service_file'], $con_svnserve_service_file); |
||||
|
||||
//启动 |
||||
echo '===============================================' . PHP_EOL; |
||||
echo '开始启动svnserve服务' . PHP_EOL; |
||||
|
||||
passthru('systemctl start svnserve'); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
//开机自启动 |
||||
echo '===============================================' . PHP_EOL; |
||||
echo '将svnserve服务加入到开机自启动' . PHP_EOL; |
||||
|
||||
passthru('systemctl enable svnserve'); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
//查看状态 |
||||
echo '===============================================' . PHP_EOL; |
||||
echo 'svnserve安装成功,打印运行状态:' . PHP_EOL; |
||||
|
||||
passthru('systemctl status svnserve'); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
} |
||||
|
||||
/** |
||||
* 程序入口 |
||||
*/ |
||||
function Run() |
||||
{ |
||||
echo '===============SVNAdmin==================' . PHP_EOL; |
||||
|
||||
foreach ($this->scripts as $value) { |
||||
echo '(' . $value['index'] . ')' . $value['note'] . PHP_EOL; |
||||
} |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
echo '请输入命令编号:'; |
||||
|
||||
$answer = trim(fgets(STDIN)); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
if (!in_array($answer, array_column($this->scripts, 'index'))) { |
||||
exit('错误的命令编号:' . PHP_EOL); |
||||
} |
||||
|
||||
if ($answer == 1) { |
||||
//帮我安装并配置Subversion |
||||
|
||||
$shellPath = BASE_PATH . '/../templete/install/WANdisco/'; |
||||
|
||||
if (!is_dir($shellPath)) { |
||||
exit('安装脚本目录不存在!' . PHP_EOL); |
||||
} |
||||
|
||||
$shell = scandir($shellPath); |
||||
|
||||
echo '可选择的Subversion版本如下:' . PHP_EOL; |
||||
|
||||
$noShell = true; |
||||
foreach ($shell as $value) { |
||||
if ($value == '.' || $value == '..') { |
||||
continue; |
||||
} |
||||
$noShell = false; |
||||
echo $value . PHP_EOL; |
||||
} |
||||
|
||||
if ($noShell) { |
||||
exit('没有可选的安装脚本!' . PHP_EOL); |
||||
} |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
echo '请注意SVNAdmin支持管理的Subversion版本为1.8+!' . PHP_EOL; |
||||
|
||||
echo '请输入要安装的Subversion版本(推荐Subversion-1.10):'; |
||||
|
||||
$answer = trim(fgets(STDIN)); |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
if (!file_exists($shellPath . 'subversion_installer_' . $answer . '.sh')) { |
||||
exit('请选择正确的版本!' . PHP_EOL); |
||||
} |
||||
|
||||
echo '现在开始执行脚本:' . 'subversion_installer_' . $answer . '.sh' . PHP_EOL; |
||||
|
||||
echo '===============================================' . PHP_EOL; |
||||
|
||||
passthru('sh ' . $shellPath . 'subversion_installer_' . $answer . '.sh'); |
||||
|
||||
$this->ConfigSubversion(); |
||||
} else if ($answer == 2) { |
||||
//按照本系统的要求初始化Subversion(针对以其它方式安装的Subversion) |
||||
$this->ConfigSubversion(); |
||||
} else if ($answer == 3) { |
||||
//检测SVNAdmin的新版本 |
||||
} |
||||
} |
||||
} |
||||
|
||||
(new Install())->Run(); |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
{ |
||||
"latestVersion": "2.3", |
||||
"fixedContent": [ |
||||
"" |
||||
], |
||||
"newContent": [ |
||||
"" |
||||
], |
||||
"updateType": "1", |
||||
"updateStep": "需要管理员手动更新 1、基于现有版本手动升级的用户 (1)停止守护进程 php svnadmind.php stop (2)删除当前版本的程序代码 (3)按照GitHub文档进行全新安装 2、全新安装的用户 (1)按照GitHub文档进行全新安装", |
||||
"releaseNode": { |
||||
"gitee": "", |
||||
"github": "" |
||||
} |
||||
} |
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
{ |
||||
"version": "2.3", |
||||
"number": 8, |
||||
"fixd": { |
||||
"con": [ |
||||
{ |
||||
"title": "1", |
||||
"content": "修复SVN仓库权限配置的bug" |
||||
}, |
||||
{ |
||||
"title": "2", |
||||
"content": "完善用户权限控制逻辑" |
||||
} |
||||
] |
||||
}, |
||||
"add": { |
||||
"con": [ |
||||
{ |
||||
"title": "1", |
||||
"content": "支持文件级授权" |
||||
}, |
||||
{ |
||||
"title": "2", |
||||
"content": "支持目录浏览" |
||||
}, |
||||
{ |
||||
"title": "3", |
||||
"content": "支持仓库备份与恢复" |
||||
}, |
||||
{ |
||||
"title": "4", |
||||
"content": "支持SVN用户禁用与启动" |
||||
}, |
||||
{ |
||||
"title": "5", |
||||
"content": "支持用户级日志记录" |
||||
}, |
||||
{ |
||||
"title": "6", |
||||
"content": "兼容PHP5.5+" |
||||
} |
||||
] |
||||
}, |
||||
"remove": { |
||||
"con": [ |
||||
{ |
||||
"title": "1", |
||||
"content": "暂时移除仓库钩子的配置功能" |
||||
} |
||||
] |
||||
}, |
||||
"update": { |
||||
"rely": { |
||||
"version": { |
||||
"SVNAdmin": [] |
||||
} |
||||
}, |
||||
"step": [ |
||||
{ |
||||
"title": "1", |
||||
"content": "php ${your_path}/server/install.php" |
||||
} |
||||
], |
||||
"release": { |
||||
"download": [ |
||||
{ |
||||
"nodeName": "gitee.com", |
||||
"releaseUrl": "" |
||||
}, |
||||
{ |
||||
"nodeName": "github.com", |
||||
"releaseUrl": "" |
||||
}, |
||||
{ |
||||
"nodeName": "witersen.com", |
||||
"releaseUrl": "https://download.witersen.com/SVNAdmin/SVNAdmin-2.3.zip" |
||||
} |
||||
] |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.10.0-2 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
if [ OSNAME="stretch" ] || [ OSNAME="bionic" ] |
||||
then |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian-new.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
else |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
fi |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.10.2-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
if [ OSNAME="stretch" ] || [ OSNAME="bionic" ] |
||||
then |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian-new.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
else |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
fi |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,495 @@
@@ -0,0 +1,495 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.10.7-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7|8) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
if [ $OSNAME = "stretch" ] || [ $OSNAME = "bionic" ] |
||||
then |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian-new.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
else |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
fi |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
if [ $OSVER = "8" ] |
||||
then yum module disable subversion -y |
||||
fi |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.11.1-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
if [ $OSNAME = "stretch" ] || [ $OSNAME = "bionic" ] |
||||
then |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian-new.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
else |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
fi |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.14.1-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
if [ $OSNAME = "stretch" ] || [ $OSNAME = "bionic" ] |
||||
then |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian-new.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
else |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
fi |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,484 @@
@@ -0,0 +1,484 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.8.19-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,484 @@
@@ -0,0 +1,484 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.9.7-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,484 @@
@@ -0,0 +1,484 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.9.9-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -0,0 +1,489 @@
@@ -0,0 +1,489 @@
|
||||
#!/bin/bash |
||||
# |
||||
# WANdisco Subversion install script. |
||||
# Copyright (C) 2013 WANdisco plc |
||||
# |
||||
# Please contact opensource@wandisco.com if you have any problems with this |
||||
# script. |
||||
|
||||
set -e |
||||
|
||||
SVN_VERSION=1.9.12-1 |
||||
REPO_SERVER=${REPO_SERVER:-opensource.wandisco.com} |
||||
ARCH=$(uname -m) |
||||
|
||||
# Functions |
||||
|
||||
function handle_error() |
||||
{ |
||||
echo |
||||
echo "There has been an error, exiting" |
||||
exit 2 |
||||
} |
||||
|
||||
function check_connection() |
||||
{ |
||||
if which curl > /dev/null 2>&1; then |
||||
GET='curl -s -f' |
||||
elif which wget > /dev/null 2>&1; then |
||||
GET='wget -O - -q' |
||||
else |
||||
echo -n "You do not have curl or wget installed. At least one of these is " |
||||
echo "required to install WANdisco Subversion" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
function check_root() |
||||
{ |
||||
test $EUID -eq 0 || |
||||
{ |
||||
echo "You need to be root to install WANdisco subversion." |
||||
echo |
||||
echo "Please re-run this script as the root user." |
||||
exit 1 |
||||
} |
||||
} |
||||
|
||||
function unsupported() |
||||
{ |
||||
echo "Your operating system is not currently supported." |
||||
echo |
||||
echo -n "Please visit http://www.wandisco.com/subversion/download for a list" |
||||
echo " of supported systems." |
||||
exit 1 |
||||
} |
||||
|
||||
function confirm() |
||||
{ |
||||
local confirm= |
||||
local message=$1 |
||||
local default=${2:-y} |
||||
local prompt= |
||||
|
||||
test -n "$NON_INTERACTIVE" && return 0 |
||||
|
||||
prompt="$message (" |
||||
if test "$default" = "y"; then |
||||
prompt="${prompt}Y/n" |
||||
else |
||||
prompt="${prompt}y/N" |
||||
fi |
||||
prompt="$prompt) " |
||||
|
||||
while test "$confirm" != "$default"; do |
||||
read -n 1 -p "$prompt" confirm |
||||
echo |
||||
confirm=${confirm:-$default} |
||||
confirm=${confirm/Y/y} |
||||
confirm=${confirm/N/n} |
||||
|
||||
if test "$default" = "y"; then |
||||
test "$confirm" = "n" && return 1 |
||||
test "$confirm" = "y" && return 0 |
||||
else |
||||
test "$confirm" = "y" && return 1 |
||||
test "$confirm" = "n" && return 0 |
||||
fi |
||||
|
||||
echo "Invalid input, please enter 'y' or 'n'" |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
function remove_other() |
||||
{ |
||||
local other=$1 |
||||
|
||||
echo -n "You currently have subversion installed for another architecture " |
||||
echo -n "($other). This should be removed before installing " |
||||
echo "WANdisco Subversion." |
||||
echo |
||||
|
||||
if ! confirm "Remove Subversion $other?"; then |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
case $OS in |
||||
rhel|centos) yum erase -y subversion.$other ;; |
||||
debian|ubuntu) apt-get -y --purge remove libsvn1:$other ;; |
||||
suse) zypper rm -y subversion.$other ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_alternative_arch() |
||||
{ |
||||
local other= |
||||
local confirm= |
||||
|
||||
case $OS in |
||||
centos|rhel|suse) |
||||
for foreign in $(rpm --showrc | awk -F: '/compatible archs/{print $2}') |
||||
do |
||||
test "$foreign" = "$ARCH" && continue |
||||
if other=$(rpm -q --queryformat='%{arch}' \ |
||||
subversion.$foreign 2>/dev/null); then |
||||
test -z "$other" && continue |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg --print-foreign-architectures >/dev/null 2>&1 || return 0 |
||||
ARCH=$(dpkg --print-architecture) |
||||
for foreign in $(dpkg --print-foreign-architectures); do |
||||
if other=$(dpkg-query -f '${Architecture}' -W libsvn1:$foreign \ |
||||
2>/dev/null); then |
||||
remove_other $other |
||||
unset other |
||||
fi |
||||
done |
||||
;; |
||||
esac |
||||
|
||||
test -z "$other" && return 0 |
||||
|
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_lsb() |
||||
{ |
||||
which lsb_release >/dev/null 2>&1 || return 1 |
||||
|
||||
OS=$(lsb_release -si | tr A-Z a-z) |
||||
OS=${OS%% *} |
||||
OSVER=$(lsb_release -sr) |
||||
OSVER=${OSVER%%.*} |
||||
OSNAME=$(lsb_release -sc | tr A-Z a-z) |
||||
|
||||
case $OS in |
||||
redhat*) |
||||
OS=rhel |
||||
;; |
||||
oracle*) |
||||
OS=rhel |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_debian() |
||||
{ |
||||
test -r /etc/debian_version || return 1 |
||||
|
||||
OS="debian" |
||||
OSVER=$(cat /etc/debian_version) |
||||
OSVER=${OSVER%%.*} |
||||
case "$OSVER" in |
||||
6) OSNAME="squeeze" ;; |
||||
7) OSNAME="wheezy" ;; |
||||
8) OSNAME="jessie" ;; |
||||
9) OSNAME="stretch" ;; |
||||
squeeze) OSNAME=$OSVER; OSVER=6 ;; |
||||
wheezy) OSNAME=$OSVER; OSVER=7 ;; |
||||
jessie) OSNAME=$OSVER; OSVER=8 ;; |
||||
stretch) OSNAME=$OSVER; OSVER=9 ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_redhat() |
||||
{ |
||||
local release= |
||||
|
||||
test -r /etc/redhat-release || return 1 |
||||
|
||||
release=$(cat /etc/redhat-release | tr A-Z a-z) |
||||
OS=${release%% release *} |
||||
OSVER=${release##* release } |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
case $OS in |
||||
red*) OS="rhel" ;; |
||||
centos*) OS="centos" ;; |
||||
*) return 1 ;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_suse() |
||||
{ |
||||
test -r /etc/SuSE-release || return 1 |
||||
|
||||
OS="suse" |
||||
OSVER=$(awk '$1 == "VERSION" {print $NF}' /etc/SuSE-release) |
||||
OSVER=${OSVER%%.*} |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function is_oracle() |
||||
{ |
||||
test -r /etc/oracle-release || return 1 |
||||
|
||||
OS="rhel" |
||||
OSVER=$(sed -e 's/.*release \([0-9]+\).*/\1/' /etc/oracle-release) |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function find_os() |
||||
{ |
||||
is_lsb && return 0 |
||||
is_redhat && return 0 |
||||
is_debian && return 0 |
||||
is_suse && return 0 |
||||
is_oracle && return 0 |
||||
|
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function check_os() |
||||
{ |
||||
case $OS in |
||||
rhel|centos) |
||||
case $OSVER in |
||||
5|6|7|8) return 0 ;; |
||||
esac |
||||
;; |
||||
suse) |
||||
case $OSVER in |
||||
11|12) return 0 ;; |
||||
esac |
||||
;; |
||||
debian) |
||||
case $OSVER in |
||||
6|7|8|9) return 0 ;; |
||||
esac |
||||
;; |
||||
ubuntu) |
||||
case $OSVER in |
||||
10|12|14|16|18) return 0 ;; |
||||
esac |
||||
;; |
||||
esac |
||||
|
||||
return 1 |
||||
} |
||||
|
||||
function find_pkg_version |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
if ! PKG_VERSION=$(rpm -q --queryformat='%{version}-%{release}' \ |
||||
subversion.$ARCH 2>/dev/null); then |
||||
return 1 |
||||
fi |
||||
;; |
||||
debian|ubuntu) |
||||
PKG_VERSION=$(dpkg-query -f='${Version}' -W subversion 2>/dev/null) |
||||
PKG_VERSION=${PKG_VERSION%%+*} |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function check_install() |
||||
{ |
||||
if ! SVN=$(svn --version --quiet 2>/dev/null); then |
||||
echo "This script will install Subversion $SVN_VERSION." |
||||
echo |
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
return 0 |
||||
fi |
||||
|
||||
find_pkg_version || |
||||
{ |
||||
echo -n "You currently have Subversion $SVN installed, however it's not " |
||||
echo -n "been installed with your systems package manager. Please remove " |
||||
echo "this version of Subversion and re-run this script." |
||||
echo |
||||
exit 2 |
||||
} |
||||
|
||||
if test "$PKG_VERSION" = "$SVN_VERSION"; then |
||||
echo "You currently have the latest version of Subversion installed." |
||||
exit 0 |
||||
fi |
||||
|
||||
echo -n "You currently have Subversion $PKG_VERSION installed. If you " |
||||
echo "continue with the installation it will be upgraded to $SVN_VERSION." |
||||
echo |
||||
|
||||
if ! confirm "Do you want to continue?"; then |
||||
echo |
||||
echo "Exiting at user request" |
||||
exit 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function configure_apt_repo() |
||||
{ |
||||
PKG_INSTALLER="apt-get -y install" |
||||
PKG_LIST="subversion libsvn-perl python-subversion subversion-tools" |
||||
|
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
rm -f /etc/apt/sources.list.d/WANdisco.list |
||||
cat <<EOF > /etc/apt/sources.list.d/WANdisco-$SVN_RELEASE.list |
||||
# WANdisco Open Source Repo |
||||
deb http://$REPO_SERVER/$OS $OSNAME $SVN_RELEASE |
||||
EOF |
||||
wget -q -O - http://$REPO_SERVER/wandisco-debian.gpg | \ |
||||
apt-key add - >/dev/null 2>&1 |
||||
apt-get update |
||||
} |
||||
|
||||
|
||||
function configure_yum_repo() |
||||
{ |
||||
PKG_INSTALLER="yum install -y" |
||||
PKG_LIST="subversion.$ARCH subversion-perl subversion-python subversion-tools" |
||||
SVN_RELEASE="${SVN_VERSION%.*}" |
||||
rm -f /etc/yum.repos.d/WANdisco.repo /etc/yum.repos.d/WANdisco-rhel?.repo |
||||
cat <<EOF > /etc/yum.repos.d/WANdisco-svn$SVN_RELEASE.repo |
||||
[WANdisco-svn${SVN_RELEASE//\./}] |
||||
name=WANdisco SVN Repo $SVN_RELEASE |
||||
enabled=1 |
||||
baseurl=http://$REPO_SERVER/$OS/$OSVER/svn-$SVN_RELEASE/RPMS/\$basearch/ |
||||
gpgcheck=1 |
||||
gpgkey=http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
EOF |
||||
if [ $OSVER = "8" ] |
||||
then yum module disable subversion -y |
||||
fi |
||||
yum makecache |
||||
} |
||||
|
||||
function configure_zypp_repo() |
||||
{ |
||||
PKG_LIST="subversion subversion-perl subversion-python subversion-tools" |
||||
PKG_LIST="$PKG_LIST subversion-ruby" |
||||
SVN_RELEASE=${SVN_VERSION%.*} |
||||
SVN_RELEASE="svn${SVN_RELEASE//\./}" |
||||
PKG_INSTALLER="zypper install -y -f --from WANdisco-$SVN_RELEASE" |
||||
|
||||
rm -f /etc/zypp/repos.d/WANdisco-suse11.repo \ |
||||
/etc/zypp/repos.d/WANdisco-svn.repo |
||||
|
||||
zypper rr WANdisco-$SVN_RELEASE > /dev/null 2>&1 |
||||
|
||||
rpm -q gpg-pubkey-3bbf077a-51260c0f >/dev/null 2>&1 || \ |
||||
rpm --import http://$REPO_SERVER/RPM-GPG-KEY-WANdisco |
||||
zypper addservice --type=YUM http://$REPO_SERVER/suse/$OSVER/$SVN_RELEASE/ \ |
||||
WANdisco-$SVN_RELEASE |
||||
zypper refresh |
||||
} |
||||
|
||||
function configure_repo() |
||||
{ |
||||
case $OS in |
||||
debian|ubuntu) configure_apt_repo ;; |
||||
rhel|centos) configure_yum_repo ;; |
||||
suse) configure_zypp_repo ;; |
||||
esac |
||||
} |
||||
|
||||
function check_mod_dav() |
||||
{ |
||||
HAS_MOD_DAV= |
||||
case $OS in |
||||
rhel|centos|suse) |
||||
rpm -q mod_dav_svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
rpm -q subversion-server > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
debian|ubuntu) |
||||
dpkg-query -W libapache2-svn > /dev/null 2>&1 && HAS_MOD_DAV=1 |
||||
return 0 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
function add_packages() |
||||
{ |
||||
case $OS in |
||||
rhel|centos|suse) return 0 ;; |
||||
esac |
||||
|
||||
PKG_LIST=$(dpkg-query -f '${Package} ${Source}\n' -W '*' | \ |
||||
awk '$2 == "subversion" {print $1}') |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function install_svn() |
||||
{ |
||||
test -n "$SVN" && add_packages |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
function install_mod_dav() |
||||
{ |
||||
test -n "$NO_MOD_DAV" && return 0 |
||||
|
||||
case $OS in |
||||
rhel|centos|suse) PKG_LIST="mod_dav_svn" ;; |
||||
debian|ubuntu) PKG_LIST="libapache2-svn" ;; |
||||
esac |
||||
|
||||
$PKG_INSTALLER $PKG_LIST |
||||
} |
||||
|
||||
# Main Script |
||||
|
||||
trap handle_error ERR |
||||
|
||||
cat <<EOF |
||||
|
||||
:: :: :: # # ## #### ###### # ##### ##### ##### |
||||
:::: :::: ::: # # # # ## ## # # # # # # # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # |
||||
::::::::::::: ::: # # # # # # # # # # # ##### # # # |
||||
::::::::::: ::: # # # # # # # # # # # # # # # |
||||
:::: :::: ::: ## ## # ## # # # # # # # # # # # |
||||
:: :: :: # # ## # # # ###### # ##### ##### ##### |
||||
|
||||
EOF |
||||
|
||||
check_connection |
||||
find_os || unsupported |
||||
check_os || unsupported |
||||
check_root |
||||
check_alternative_arch |
||||
check_install |
||||
configure_repo |
||||
check_mod_dav |
||||
install_svn |
||||
|
||||
echo "Subversion has been installed or upgraded successfully" |
||||
|
||||
test -n "$HAS_MOD_DAV" && exit 0 |
||||
|
||||
echo |
||||
echo "Do you want to install the subversion server modules for apache?" |
||||
echo |
||||
if confirm "Install mod_dav_svn?"; then |
||||
install_mod_dav |
||||
fi |
||||
|
||||
echo |
||||
echo "Installation complete" |
@ -1,2 +1 @@
@@ -1,2 +1 @@
|
||||
//OPTIONS="-r /home/svnadmin/rep --config-file /home/svnadmin/svnserve.conf --log-file /home/svnadmin/logs/svnserve/svnserve.log" |
||||
OPTIONS="-r '%s' --config-file '%s' --log-file '%s' --listen-port 3690 --listen-host 0.0.0.0" |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
[Unit] |
||||
Description=Subversion protocol daemon |
||||
After=syslog.target network.target |
||||
|
||||
[Service] |
||||
Type=forking |
||||
EnvironmentFile=%s |
||||
ExecStart=%s --daemon --pid-file=%s $OPTIONS |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
Loading…
Reference in new issue