提交 592e5bd3 编写于 作者: T TommyLike

Add obs server/worker start scripts

上级 96004b3f
......@@ -169,8 +169,8 @@ our $serviceserver = "http://<ip address of backend server>:5152";
```
3. update the slp files
```bash
1. /etc/slp.reg.d/obs_repo_server.reg
2. /etc/slp.reg.d/obs_source_server.reg
1. /etc/slp.reg.d/obs.repo_server.reg
2. /etc/slp.reg.d/obs.source_server.reg
```
......
[general]
# URL to access API server, e.g. https://api.opensuse.org
# you also need a section [https://api.opensuse.org] with the credentials
apiurl = https://build.openeuler.org
# Downloaded packages are cached here. Must be writable by you.
#packagecachedir = /var/tmp/osbuild-packagecache
# Wrapper to call build as root (sudo, su -, ...)
#su-wrapper = sudo
# rootdir to setup the chroot environment
# can contain %(repo)s, %(arch)s, %(project)s, %(package)s and %(apihost)s (apihost is the hostname
# extracted from currently used apiurl) for replacement, e.g.
# /srv/oscbuild/%(repo)s-%(arch)s or
# /srv/oscbuild/%(repo)s-%(arch)s-%(project)s-%(package)s
#build-root = /var/tmp/build-root/%(repo)s-%(arch)s
# compile with N jobs (default: "getconf _NPROCESSORS_ONLN")
#build-jobs = N
# build-type to use - values can be (depending on the capabilities of the 'build' script)
# empty - chroot build
# kvm - kvm VM build (needs build-device, build-swap, build-memory)
# xen - xen VM build (needs build-device, build-swap, build-memory)
# experimental:
# qemu - qemu VM build
# lxc - lxc build
#build-type =
# build-device is the disk-image file to use as root for VM builds
# e.g. /var/tmp/FILE.root
#build-device = /var/tmp/FILE.root
# build-swap is the disk-image to use as swap for VM builds
# e.g. /var/tmp/FILE.swap
#build-swap = /var/tmp/FILE.swap
# build-kernel is the boot kernel used for VM builds
#build-kernel = /boot/vmlinuz
# build-initrd is the boot initrd used for VM builds
#build-initrd = /boot/initrd
# build-memory is the amount of memory used in the VM
# value in MB - e.g. 512
#build-memory = 512
# build-vmdisk-rootsize is the size of the disk-image used as root in a VM build
# values in MB - e.g. 4096
#build-vmdisk-rootsize = 4096
# build-vmdisk-swapsize is the size of the disk-image used as swap in a VM build
# values in MB - e.g. 1024
#build-vmdisk-swapsize = 1024
# build-vmdisk-filesystem is the file system type of the disk-image used in a VM build
# values are ext3(default) ext4 xfs reiserfs btrfs
#build-vmdisk-filesystem = ext4
# Numeric uid:gid to assign to the "abuild" user in the build-root
# or "caller" to use the current users uid:gid
# This is convenient when sharing the buildroot with ordinary userids
# on the host.
# This should not be 0
# build-uid =
# strip leading build time information from the build log
# buildlog_strip_time = 1
# extra packages to install when building packages locally (osc build)
# this corresponds to osc build's -x option and can be overridden with that
# -x '' can also be given on the command line to override this setting, or
# you can have an empty setting here.
#extra-pkgs = vim gdb strace
# build platform is used if the platform argument is omitted to osc build
#build_repository = openSUSE_Factory
# default project for getpac or bco
#getpac_default_project = openSUSE:Factory
# alternate filesystem layout: have multiple subdirs, where colons were.
#checkout_no_colon = 0
# change filesystem layout: avoid checkout within a project or package dir.
#checkout_rooted = 0
# local files to ignore with status, addremove, ....
#exclude_glob = .osc CVS .svn .* _linkerror *~ #*# *.orig *.bak *.changes.vctmp.*
# keep passwords in plaintext.
# Set to 0 to obfuscate passwords. It's no real security, just
# prevents most people from remembering your password if they watch
# you editing this file.
#plaintext_passwd = 1
# limit the age of requests shown with 'osc req list'.
# this is a default only, can be overridden by 'osc req list -D NNN'
# Use 0 for unlimted.
#request_list_days = 0
# show info useful for debugging
#debug = 1
# show HTTP traffic useful for debugging
#http_debug = 1
# number of retries on HTTP transfer
#http_retries = 3
# Skip signature verification of packages used for build.
#no_verify = 1
# jump into the debugger in case of errors
#post_mortem = 1
# print call traces in case of errors
#traceback = 1
# use KDE/Gnome/MacOS/Windows keyring for credentials if available
#use_keyring = 1
# check for unversioned/removed files before commit
#check_filelist = 1
# check for pending requests after executing an action (e.g. checkout, update, commit)
#check_for_request_on_action = 0
# what to do with the source package if the submitrequest has been accepted. If
# nothing is specified the API default is used
#submitrequest_on_accept_action = cleanup|update|noupdate
# template for an accepted submitrequest
#submitrequest_accepted_template = Hi %(who)s,\n
# thanks for working on:\t%(tgt_project)s/%(tgt_package)s.
# SR %(reqid)s has been accepted.\n\nYour maintainers
# template for a declined submitrequest
#submitrequest_declined_template = Hi %(who)s,\n
# sorry your SR %(reqid)s (request type: %(type)s) for
# %(tgt_project)s/%(tgt_package)s has been declined because...
#review requests interactively (default: off)
#request_show_review = 1
# if a review is accepted in interactive mode and a group
# was specified the review will be accepted for this group (default: off)
#review_inherit_group = 1
[https://build.openeuler.org]
user = Admin
pass = opensuse
# set aliases for this apiurl
# aliases = foo, bar
# real name used in .changes, unless the one from osc meta prj <user> will be used
# realname =
# email used in .changes, unless the one from osc meta prj <user> will be used
# email =
# additional headers to pass to a request, e.g. for special authentication
#http_headers = Host: foofoobar,
# User: mumblegack
# Plain text password
#pass =
# Force using of keyring for this API
#keyring = 1
\ No newline at end of file
#!/bin/bash
set -e
if [[ $# -lt 2 ]];then
echo "please input obs_repo_ip obs_src_ip"
exit 2
fi
obs_repo_ip=$1
obs_src_ip=$2
OBS_INSTALL_DIR=/tmp/obs_worker_arm_install
install_rpms="ntpdate vim cpio curl perl-Compress-Zlib perl-TimeDate perl-Data-Dumper perl-XML-Parser screen psmisc bash binutils bsdtar lzma util-linux openslp lvm2 perl-Digest-MD5 osc git screen tmux wget expect"
function fn_prepare_repos()
{
[ ! -d $OBS_INSTALL_DIR ] && mkdir -p $OBS_INSTALL_DIR
# download obsworker scripts
if [ ! -e $OBS_INSTALL_DIR/obsworker.tar.gz ]; then
curl http://10.120.107.75/xdf/obsworker.tar.gz -o $OBS_INSTALL_DIR/obsworker.tar.gz
fi
}
function fn_config_umask()
{
sed -i s'/umask 0077/umask 0022/g' /etc/bashrc
}
function fn_config_disk()
{
disk=$1
if [ "x$disk" == "x" ];then
echo "please disk name"
exit 1
fi
if [ ! -e $disk ];then
echo "No date disk $disk"
exit 1
fi
if [ ! -d /var/cache/obs/worker/ ];then
mkdir -p /var/cache/obs/worker/
fi
if [ ! -e /dev/OBS/worker ];then
pvcreate $disk
vgcreate "OBS" $disk
lvcreate -l 100%FREE "OBS" -n "worker"
mkfs.ext3 /dev/OBS/worker
echo "/dev/mapper/OBS-worker /var/cache/obs/worker ext3 defaults 0 0" >> /etc/fstab
mount -a
fi
}
function fn_install_obsworker()
{
if [ ! -e /etc/sysconfig/obs-server ];then
tar -xvf $OBS_INSTALL_DIR/obsworker.tar.gz -C /
fi
## add obsrun group
getent group obsrun >/dev/null || groupadd -r obsrun
## add obsrun user
getent passwd obsrun >/dev/null || /usr/sbin/useradd -r -g obsrun -d /usr/lib/obs -s /usr/sbin/nologin -c "User for build service backend" obsrun
}
function fn_install_rpms()
{
[ ! -d $OBS_INSTALL_DIR ] && mkdir -p $OBS_INSTALL_DIR
yum -y install ${install_rpms}
# repo_conf=$OBS_INSTALL_DIR/centos7.5-obs-repo.conf
# if [ -e "$repo_conf" ];then
# rm -rf "$repo_conf"
# fi
#
# touch $OBS_INSTALL_DIR/centos7.5-obs-repo.conf
#
## notice no indent
# cat >$repo_conf << EOF
#[main]
#cachedir=/var/cache/yum/xxx
#keepcache=0
#debuglevel=2
#logfile=/var/log/yum.log
#exactarch=1
#obsoletes=1
#gpgcheck=1
#plugins=1
#installonly_limit=3
#reposdir=/xxx
#
#[centso7.5-aarch64]
#name=centos7.5-aarch64
#baseurl=http://10.175.100.158/iso/centos/7.5/CentOS-7-aarch64/
#enabled=1
#gpgcheck=0
#
#[centos7.5-osc]
#name=centos7.5-osc
#baseurl=http://10.120.107.75/OBS:/Server:/2.9/centos_7_osc/
#enabled=1
#gpgcheck=0
#EOF
#
# yum -c $repo_conf clean all
# yum -y install -c $repo_conf ${install_rpms}
}
#function fn_config_hostname()
#{
# n=`lscpu | grep '^CPU(s):' | awk '{print $2}'`
# DEFAULT_ROUTE_INTERFACE=`LANG=C ip route show|perl -e '$_=<>; ( m/^default via.*dev\s+([\w]+)\s.*/ ) && print $1'`
# FQHOSTNAME=`LANG=C ip addr show $DEFAULT_ROUTE_INTERFACE| perl -lne '( m#^\s+inet\s+([0-9\.]+)(/\d+)?\s+.*# ) && print $1' | grep -v ^127. | head -n 1`
# hostname="arm${n}u${FQHOSTNAME//\./b}"
# hostnamectl set-hostname ${hostname}
#}
function fn_config_obs_server_file()
{
n=`lscpu | grep '^CPU(s):' | awk '{print $2}'`
let n=$n/4+1
sed -i "s/OBS_SRC_SERVER=.*/OBS_SRC_SERVER=\"$obs_src_ip:5352\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_REPO_SERVERS=.*/OBS_REPO_SERVERS=\"$obs_repo_ip:5252\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_WORKER_INSTANCES=.*/OBS_WORKER_INSTANCES=\"$n\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_WORKER_JOBS=.*/OBS_WORKER_JOBS=\"8\"/g" /etc/sysconfig/obs-server
}
#function fn_config_hosts()
#{
# sed -i '/euleros-obs-repo/d' /etc/hosts
# sed -i '/euleros-obs/d' /etc/hosts
#
# sed -i "1i $obs_repo_ip euleros-obs-repo euleros-obs-repo.huawei.com" /etc/hosts
# sed -i "1i $obs_ui_ip euleros-obs euleros-obs.huawei.com" /etc/hosts
#
#}
function fn_restart_obsworker()
{
systemctl enable obsworker.service
systemctl restart obsworker.service
}
#function fn_sync_time()
#{
# # sync time
# /usr/sbin/ntpdate 172.19.1.63 &> /dev/null
# /usr/sbin/ntpdate 172.19.1.64 &> /dev/null
# /usr/sbin/ntpdate 172.19.64.32 &> /dev/null
#
# # set utc time
# rm -rf /etc/localtime
# ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
#
#
# if ! grep "172.19.64.32" /var/spool/cron/root ;then
# echo "0 * * * * /usr/sbin/ntpdate 172.19.1.63 >> /var/log/szntp01.log 2>&1" >> /var/spool/cron/root
# echo "30 * * * * /usr/sbin/ntpdate 172.19.1.64 >> /var/log/szntp02.log 2>&1" >> /var/spool/cron/root
# echo "45 * * * * /usr/sbin/ntpdate 172.19.64.32 >> /var/log/nkgntp01.log 2>&1" >> /var/spool/cron/root
# fi
#}
#function fn_config_firewall()
#{
# systemctl stop firewalld.service
# systemctl disable firewalld.service
# ## disable SELinux
# ### disable SELinux temporarily
# setenforce 0
# ### disable SELinux permanently
# sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
#}
fn_main()
{
fn_prepare_repos
fn_config_umask
#fn_config_disk /dev/sdb
fn_install_rpms
fn_install_obsworker
#fn_sync_time
fn_config_obs_server_file
#fn_config_hostname
#fn_config_hosts
#fn_config_firewall
fn_restart_obsworker
}
fn_main
# NOTE
All script files in this folder used to start up the corresponding service in OBS cluster
# Frontend
## Requirement
It's assumed the system is booted via the OpenSUSE OBS 2.10 ISO image [here](https://openbuildservice.org/download/)
## Setup environment
Frontend is used to running the api server including the memcached and mysql, please copy the `frontend.sh` file
to any folder of the destination machine and execute the command:
```bash
./frontend.sh <ip address of source service>
```
and the status of the service can be checked with command:
```bash
systemctl list-units | grep -E 'obs|memcached|mariadb|apache2'
```
the output would be like:
```bash
apache2.service loaded active running The Apache Webserver
mariadb.service loaded active running MySQL server
memcached.service loaded active running memcached daemon
obs-clockwork.service loaded active running Open Build Service Clockwork Daemon
obs-delayedjob-queue-consistency_check.service loaded active running Open Build Service DelayedJob Queue: consistency_check
obs-delayedjob-queue-default.service loaded active running Open Build Service DelayedJob Queue: default
obs-delayedjob-queue-issuetracking.service loaded active running Open Build Service DelayedJob Queue: issuetracking
obs-delayedjob-queue-mailers.service loaded active running Open Build Service DelayedJob Queue: mailers
obs-delayedjob-queue-project_log_rotate.service loaded active running Open Build Service DelayedJob Queue: project_log_rotate
obs-delayedjob-queue-quick@0.service loaded active running Open Build Service DelayedJob Queue Instance: quick
obs-delayedjob-queue-quick@1.service loaded active running Open Build Service DelayedJob Queue Instance: quick
obs-delayedjob-queue-quick@2.service loaded active running Open Build Service DelayedJob Queue Instance: quick
obs-delayedjob-queue-releasetracking.service loaded active running Open Build Service DelayedJob Queue: releasetracking
obs-delayedjob-queue-staging.service loaded active running Open Build Service DelayedJob Queue: staging
obs-sphinx.service loaded active running Open Build Service Sphinx Search Daemon
obsstoragesetup.service loaded active exited OBS storage setup
system-obs\x2ddelayedjob\x2dqueue\x2dquick.slice loaded active active system-obs\x2ddelayedjob\x2dqueue\x2dquick.slice
obs-api-support.target loaded active active Open Build Service API Support Daemons
```
## Source Service
## Requirement
It's assumed the system is booted via the OpenSUSE OBS 2.10 ISO image [here](https://openbuildservice.org/download/)
## Setup environment
Source service is used to running the OBS source server (including obsdeltastore.service and obsservicedispatch.service)
please copy the `source_server.sh` file to any folder of the destination machine and execute the command:
```bash
./source_server.sh <ip address of source host> <ip address of backend host>
```
and the status of the service can be checked with command:
```bash
systemctl list-units | grep obs
```
the output would include:
```bash
obsdeltastore.service loaded active running OBS deltastore daemon
obsservicedispatch.service loaded active running OBS source service dispatcher
obssrcserver.service loaded active running OBS source repository server
obsstoragesetup.service loaded active exited OBS storage setup
```
## Backend Service
## Requirement
It's assumed the system is booted via the OpenSUSE OBS 2.10 ISO image [here](https://openbuildservice.org/download/)
## Setup environment
Backend service is used to running the OBS repo server, scheduler, warden and any service used to dispatch%execute&upload builds
please copy the `backend.sh` file to any folder of the destination machine and execute the command:
```bash
./backend.sh <ip address of source host> <ip address of backend host>
```
and the status of the service can be checked with command:
```bash
systemctl list-units | grep obs
```
the output would include:
```bash
obsapisetup.service loaded activating start start OBS API Setup
obsdispatcher.service loaded active running OBS job dispatcher daemon
obsdodup.service loaded active running OBS dodup, updates download on demand metadata
obspublisher.service loaded active running OBS repository publisher
obsrepserver.service loaded active running OBS repository server
obsscheduler.service loaded active exited OBS job scheduler
obsservice.service loaded active running OBS source service server
obssignd.service loaded active running LSB: start the gpg sign daemon
obssigner.service loaded active running OBS signer service
obsstoragesetup.service loaded active exited OBS storage setup
obswarden.service loaded active running OBS warden, monitors the workers
system-obs\x2ddelayedjob\x2dqueue\x2dquick.slice loaded active active system-obs\x2ddelayedjob\x2dqueue\x2dquick.slice
```
## Worker Service
## Requirement
It's assumed the system is based on Centos, equal to Centos7.6 is prefered and there is additional volumes are mounted (used for obs worker working folder)
## Setup environment
Worker service is used to running the OBS worker server.
please copy the `worker.sh` file to any folder of the destination machine and execute the command:
```bash
./worker.sh <ip address of source host> <ip address of backend host> <disk name that will be used>
```
and the status of the service can be checked with command:
```bash
systemctl list-units | grep obs
```
the output would include:
```bash
var-cache-obs-worker.mount loaded active mounted /var/cache/obs/worker
obsworker.service loaded active running LSB: Open Build Service worker
```
#!/bin/bash
if [[ $# -lt 4 ]];then
echo "please specify frontend host, source host. backend host and repo ID of source server, usage: ./backend.sh 117.78.1.88 172.16.1.87 172.16.1.81 116267610"
exit 1
fi
frontend_host=$1
source_host=$2
backend_host=$3
repo_id=$4
#ensure the system matches
system_info=`uname -r`
if [[ ! ${system_info} == '4.12.14-lp151.28.7-default' ]];then
echo "this script is strictly bound to specific release `4.12.14-lp151.28.7-default`, please ensure this script works on your system"
exit 1
fi
echo "Starting obs backend service with source server ${source_host}.."
#enable and start sshd service
echo "Enabling sshd service if not enabled"
systemctl enable sshd.service
echo "Disabling all service before start"
# disable all obs service first
systemctl disable obssrcserver.service
systemctl disable obsrepserver.service
systemctl disable obsservice.service
systemctl disable obsdodup.service
systemctl disable obssignd.service
systemctl disable obsservicedispatch.service
systemctl disable obsdeltastore.service
systemctl disable obsscheduler.service
systemctl disable obsdispatcher.service
systemctl disable obspublisher.service
systemctl disable obssigner.service
systemctl disable obswarden.service
systemctl disable obsworker.service
systemctl disable apache2
systemctl disable mysql
systemctl disable memcached
systemctl disable obs-api-support.target
systemctl stop obssrcserver.service
systemctl stop obsrepserver.service
systemctl stop obsservice.service
systemctl stop obsdodup.service
systemctl stop obssignd.service
systemctl stop obsservicedispatch.service
systemctl stop obsdeltastore.service
systemctl stop obsscheduler.service
systemctl stop obsdispatcher.service
systemctl stop obspublisher.service
systemctl stop obssigner.service
systemctl stop obswarden.service
systemctl stop obsworker.service
systemctl stop apache2
systemctl stop mysql
systemctl stop memcached
systemctl stop obs-api-support.target
# update configuration file
echo "Updating configuration file for obs backend service"
sed -i "s/when you touch hostname or port/when you touch hostname\n\$ipaccess->{'^172\\\.16\\\..*'} = 'rw' ;/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$srcserver = \"http:\/\/\$hostname:5352\";/our \$srcserver = \"http:\/\/${source_host}:5352\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$reposerver = \"http:\/\/\$hostname:5252\";/our \$reposerver = \"http:\/\/${backend_host}:5252\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$serviceserver = \"http:\/\/\$hostname:5152\";/our \$serviceserver = \"http:\/\/${backend_host}:5152\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/\$HOSTNAME/${backend_host}/g" /etc/slp.reg.d/obs.repo_server.reg
sed -i "s/\$HOSTNAME/${source_host}/g" /etc/slp.reg.d/obs.source_server.reg
sed -i "s/After=network.target obssrcserver.service obsrepserver.service obsapisetup.service/After=network.target obssrcserver.service obsrepserver.service/g" /usr/lib/systemd/system/obsscheduler.service
systemctl daemon-reload
# update hosts info
if ! grep -q "${frontend_host} build.openeuler.org" /etc/hosts; then
echo "${frontend_host} build.openeuler.org" >> /etc/hosts
fi
echo "updating the osc configuration files"
#update osc config file
if [[ ! -d /root/.config/osc ]];then
mkdir -p /root/.config/osc
fi
if [[ ! -e /root/.config/osc/oscrc ]];then
rm /root/.config/osc/oscrc
curl -o oscrc https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/oscrc
fi
echo "updating the content of _repoid file"
echo ${repo_id} > /srv/obs/build/_repoid
echo ${repo_id} > /srv/obs/projects/_repoid
echo "Restarting backend service"
# restart the frontend service
systemctl enable obsrepserver.service
systemctl enable obsservice.service
systemctl enable obsdodup.service
systemctl enable obssignd.service
systemctl enable obsscheduler.service
systemctl enable obsdispatcher.service
systemctl enable obspublisher.service
systemctl enable obssigner.service
systemctl enable obswarden.service
systemctl start obsrepserver.service
systemctl start obsservice.service
systemctl start obsdodup.service
systemctl start obssignd.service
systemctl start obsscheduler.service
systemctl start obsdispatcher.service
systemctl start obspublisher.service
systemctl start obssigner.service
systemctl start obswarden.service
echo "OBS backend server successfully started"
#!/bin/bash
###############################################################################
function prepare_database_setup {
cd /srv/www/obs/api
RAILS_ENV=production bin/rails db:migrate:status > /dev/null
if [[ $? > 0 ]];then
echo "Initialize MySQL databases (first time only)"
echo " - reconfiguring /etc/my.cnf"
perl -p -i -e 's#.*datadir\s*=\s*/var/lib/mysql$#datadir= /srv/obs/MySQL#' /etc/my.cnf
echo " - installing to new datadir"
mysql_install_db
echo " - changing ownership for new datadir"
chown mysql:mysql -R /srv/obs/MySQL
echo " - restarting mysql"
systemctl restart mysql
do
logline " - Doing 'rails $cmd'"
RAILS_ENV=production bin/rails $cmd >> $apidir/log/db_migrate.log
if [[ $? > 0 ]];then
(>&2 echo "Command $cmd FAILED")
exit 1
echo " - setting new password for user root in mysql"
mysqladmin -u root password "opensuse"
if [[ $? > 0 ]];then
echo "ERROR: Your mysql setup doesn't fit your rails setup"
echo "Please check your database settings for mysql and rails"
exit 1
fi
RUN_INITIAL_SETUP="true"
fi
RAKE_COMMANDS=""
if [ -n "$RUN_INITIAL_SETUP" ]; then
logline "Initialize OBS api database (first time only)"
cd $apidir
RAKE_COMMANDS="db:create db:setup writeconfiguration"
else
logline "Migrate OBS api database"
cd $apidir
RAKE_COMMANDS="db:migrate:with_data"
echo
fi
logline "Setting ownership of '$backenddir' obsrun"
chown obsrun.obsrun $backenddir
logline "Setting up rails environment"
for cmd in $RAKE_COMMANDS
do
logline " - Doing 'rails $cmd'"
RAILS_ENV=production bin/rails $cmd >> $apidir/log/db_migrate.log
if [[ $? > 0 ]];then
(>&2 echo "Command $cmd FAILED")
exit 1
fi
done
if [ -n "$RUN_INITIAL_SETUP" ]; then
if [[ ! "$SETUP_ONLY" ]];then
`systemctl restart obsscheduler.service`
fi
fi
}
\ No newline at end of file
if [[ $# -lt 2 ]];then
echo "please specify frontend host, source host,usage: ./frontend.sh 117.78.1.88 172.16.1.87"
exit 1
fi
frontend_host=$1
source_host=$2
#ensure the system matches
system_info=`uname -r`
if [[ ! ${system_info} == '4.12.14-lp151.28.7-default' ]];then
echo "this script is strictly bound to specific release `4.12.14-lp151.28.7-default`, please ensure this script works on your system"
exit 1
fi
echo "Starting obs api service with source server ${source_host}.."
#enable and start sshd service
echo "Enabling sshd service if not enabled"
systemctl enable sshd.service
echo "Disabling all service before start"
# disable all obs service first
systemctl disable obssrcserver.service
systemctl disable obsrepserver.service
systemctl disable obsservice.service
systemctl disable obsdodup.service
systemctl disable obssignd.service
systemctl disable obsservicedispatch.service
systemctl disable obsdeltastore.service
systemctl disable obsscheduler.service
systemctl disable obsdispatcher.service
systemctl disable obspublisher.service
systemctl disable obssigner.service
systemctl disable obswarden.service
systemctl disable obsworker.service
systemctl disable apache2
systemctl disable mysql
systemctl disable memcached
systemctl disable obs-api-support.target
systemctl stop obssrcserver.service
systemctl stop obsrepserver.service
systemctl stop obsservice.service
systemctl stop obsdodup.service
systemctl stop obssignd.service
systemctl stop obsservicedispatch.service
systemctl stop obsdeltastore.service
systemctl stop obsscheduler.service
systemctl stop obsdispatcher.service
systemctl stop obspublisher.service
systemctl stop obssigner.service
systemctl stop obswarden.service
systemctl stop obsworker.service
systemctl stop apache2
systemctl stop mysql
systemctl stop memcached
systemctl stop obs-api-support.target
# downloading cert files
cd /srv/obs/certs
curl -o fullchain.pem https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/frontend/certs/fullchain.pem
curl -o privkey.pem https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/frontend/certs/privkey.pem
# update configuration file
echo "Updating configuration file for apache service"
sed -i "s/source_host: localhost/source_host: ${source_host}/g" /srv/www/obs/api/config/options.yml
sed -i "s/ServerName api/ServerName build.openeuler.org/g" /etc/apache2/vhosts.d/obs.conf
sed -i "s/SSLCertificateFile \/srv\/obs\/certs\/server.crt/SSLCertificateFile \/srv\/obs\/certs\/fullchain.pem/g" /etc/apache2/vhosts.d/obs.conf
sed -i "s/SSLCertificateKeyFile \/srv\/obs\/certs\/server.key/SSLCertificateKeyFile \/srv\/obs\/certs\/privkey.pem/g" /etc/apache2/vhosts.d/obs.conf
# configure osc and api hostname
sed -i "s/our \$srcserver = \"http:\/\/\$hostname:5352\";/our \$srcserver = \"http:\/\/${source_host}:5352\";/g" /usr/lib/obs/server/BSConfig.pm
hostnamectl set-hostname build.openeuerl.org
# update hosts info
if ! grep -q "${frontend_host} build.openeuler.org" /etc/hosts; then
echo "${frontend_host} build.openeuler.org" >> /etc/hosts
fi
echo "updating the osc configuration files"
#update osc config file
if [[ ! -d /root/.config/osc ]];then
mkdir -p /root/.config/osc
fi
if [[ ! -e /root/.config/osc/oscrc ]];then
rm /root/.config/osc/oscrc
curl -o oscrc https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/oscrc
fi
echo "Restarting frontend service"
# restart the frontend service
systemctl enable obs-api-support.target
systemctl enable mysql
systemctl enable memcached
systemctl enable apache2
systemctl start obs-api-support.target
systemctl start mysql
systemctl start memcached
systemctl start apache2
echo "OBS frontend server successfully started"
#!/bin/bash
if [[ $# -lt 3 ]];then
echo "please specify frontend host, source host and backend host, usage: ./source_server.sh 117.78.1.88 172.16.1.87 172.16.1.81"
exit 1
fi
frontend_host=$1
source_host=$2
backend_host=$3
#ensure the system matches
system_info=`uname -r`
if [[ ! ${system_info} == '4.12.14-lp151.28.7-default' ]];then
echo "this script is strictly bound to specific release `4.12.14-lp151.28.7-default`, please ensure this script works on your system"
exit 1
fi
echo "Starting obs source service with backend server ${backend_host}.."
#enable and start sshd service
echo "Enabling sshd service if not enabled"
systemctl enable sshd.service
echo "Disabling all service before start"
# disable all obs service first
systemctl disable obssrcserver.service
systemctl disable obsrepserver.service
systemctl disable obsservice.service
systemctl disable obsdodup.service
systemctl disable obssignd.service
systemctl disable obsservicedispatch.service
systemctl disable obsdeltastore.service
systemctl disable obsscheduler.service
systemctl disable obsdispatcher.service
systemctl disable obspublisher.service
systemctl disable obssigner.service
systemctl disable obswarden.service
systemctl disable obsworker.service
systemctl disable apache2
systemctl disable mysql
systemctl disable memcached
systemctl disable obs-api-support.target
systemctl stop obssrcserver.service
systemctl stop obsrepserver.service
systemctl stop obsservice.service
systemctl stop obsdodup.service
systemctl stop obssignd.service
systemctl stop obsservicedispatch.service
systemctl stop obsdeltastore.service
systemctl stop obsscheduler.service
systemctl stop obsdispatcher.service
systemctl stop obspublisher.service
systemctl stop obssigner.service
systemctl stop obswarden.service
systemctl stop obsworker.service
systemctl stop apache2
systemctl stop mysql
systemctl stop memcached
systemctl stop obs-api-support.target
# update configuration file
echo "Updating configuration file for obs source service"
sed -i "s/when you touch hostname or port/when you touch hostname\n\$ipaccess->{'^172\\\.16\\\..*'} = 'rw' ;/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$srcserver = \"http:\/\/\$hostname:5352\";/our \$srcserver = \"http:\/\/${source_host}:5352\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$reposerver = \"http:\/\/\$hostname:5252\";/our \$reposerver = \"http:\/\/${backend_host}:5252\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/our \$serviceserver = \"http:\/\/\$hostname:5152\";/our \$serviceserver = \"http:\/\/${backend_host}:5152\";/g" /usr/lib/obs/server/BSConfig.pm
sed -i "s/\$HOSTNAME/${backend_host}/g" /etc/slp.reg.d/obs.repo_server.reg
sed -i "s/\$HOSTNAME/${source_host}/g" /etc/slp.reg.d/obs.source_server.reg
# update hosts info
if ! grep -q "${frontend_host} build.openeuler.org"; then
echo "${frontend_host} build.openeuler.org" >> /etc/hosts
fi
echo "updating the osc configuration files"
#update osc config file
if [[ ! -d /root/.config/osc ]];then
mkdir -p /root/.config/osc
fi
if [[ ! -e /root/.config/osc/oscrc ]];then
rm /root/.config/osc/oscrc
curl -o oscrc https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/oscrc
fi
echo "Restarting source service"
# restart the frontend service
systemctl enable obsstoragesetup.service
systemctl enable obssrcserver.service
systemctl enable obsdeltastore.service
systemctl enable obsservicedispatch.service
systemctl start obsstoragesetup.service
systemctl start obssrcserver.service
systemctl start obsdeltastore.service
systemctl start obsservicedispatch.service
echo "OBS source server successfully started"
SOURCE_REPO_ID=`cat /srv/obs/projects/_repoid`
echo "Important, Please use this ID: ${SOURCE_REPO_ID} to replace the file content of '/srv/obs/projects/_repoid' and '/srv/obs/build/_repoid' in the backend server"
#!/bin/bash
function fn_install_obsworker()
{
if [[ ! -e /etc/sysconfig/obs-server ]];then
tar -xvf $OBS_INSTALL_DIR/obsworker.tar.gz -C /
fi
## add obsrun group
getent group obsrun >/dev/null || groupadd -r obsrun
## add obsrun user
getent passwd obsrun >/dev/null || /usr/sbin/useradd -r -g obsrun -d /usr/lib/obs -s /usr/sbin/nologin -c "User for build service backend" obsrun
}
function fn_config_obs_server_file()
{
n=`lscpu | grep '^CPU(s):' | awk '{print $2}'`
let n=$n/4+1
sed -i "s/OBS_SRC_SERVER=.*/OBS_SRC_SERVER=\"${source_host}:5352\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_REPO_SERVERS=.*/OBS_REPO_SERVERS=\"${backend_host}:5252\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_WORKER_INSTANCES=.*/OBS_WORKER_INSTANCES=\"$n\"/g" /etc/sysconfig/obs-server
sed -i "s/OBS_WORKER_JOBS=.*/OBS_WORKER_JOBS=\"8\"/g" /etc/sysconfig/obs-server
}
function fn_config_disk()
{
if [[ ! -e ${disk_name} ]];then
echo "No date disk ${disk_name}"
exit 1
fi
if [[ ! -d /var/cache/obs/worker/ ]];then
mkdir -p /var/cache/obs/worker/
fi
if [[ ! -e /dev/OBS/worker ]];then
pvcreate ${disk_name}
vgcreate "OBS" ${disk_name}
lvcreate -l 100%FREE "OBS" -n "worker"
mkfs.ext3 /dev/OBS/worker
echo "/dev/mapper/OBS-worker /var/cache/obs/worker ext3 defaults 0 0" >> /etc/fstab
mount -a
fi
}
if [[ $# -lt 3 ]];then
echo "please specify source host and backend host and worker disk name, for instance: ./worker.sh 172.16.1.87 172.16.1.81 /dev/vdb"
exit 1
fi
source_host=$1
backend_host=$2
disk_name=$3
echo "Starting obs worker service with backend server ${backend_host}.."
#enable and start sshd service
echo "Enabling sshd service if not enabled"
systemctl enable sshd.service
echo "installing requirement packages"
yum install -y ntpdate vim cpio curl perl-Compress-Zlib perl-TimeDate perl-Data-Dumper perl-XML-Parser screen psmisc bash binutils bsdtar lzma util-linux openslp lvm2 perl-Digest-MD5 osc git screen tmux wget expect
echo "downloading obs worker script files"
OBS_INSTALL_DIR=/tmp/obs_worker_arm_install
[[ ! -d ${OBS_INSTALL_DIR} ]] && mkdir -p ${OBS_INSTALL_DIR}
if [[ ! -e ${OBS_INSTALL_DIR}/obsworker.tar.gz ]]; then
curl https://gitee.com/openeuler/infrastructure/raw/master/obs/tf/configuration_files/worker/obsworker.tar.gz -o ${OBS_INSTALL_DIR}/obsworker.tar.gz
fi
echo "configure disks"
fn_config_disk
echo "unmask config"
sed -i s'/umask 0077/umask 0022/g' /etc/bashrc
echo "installing obsworker"
fn_install_obsworker
echo "updating obs worker configuration file"
fn_config_obs_server_file
echo "enabling obs worker service"
systemctl enable obsworker.service
systemctl start obsworker.service
echo "OBS worker successfully started"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册