summaryrefslogtreecommitdiff
path: root/devobsserver/script
diff options
context:
space:
mode:
Diffstat (limited to 'devobsserver/script')
-rwxr-xr-xdevobsserver/script/ca.sh64
-rwxr-xr-xdevobsserver/script/db.sh24
-rwxr-xr-xdevobsserver/script/initdb.sh54
-rwxr-xr-xdevobsserver/script/obsservice.sh49
-rwxr-xr-xdevobsserver/script/repos.sh39
-rwxr-xr-xdevobsserver/script/restart_obs.sh61
-rwxr-xr-xdevobsserver/script/rsync.sh43
-rwxr-xr-xdevobsserver/script/startup.sh32
8 files changed, 366 insertions, 0 deletions
diff --git a/devobsserver/script/ca.sh b/devobsserver/script/ca.sh
new file mode 100755
index 0000000..a9c9fe9
--- /dev/null
+++ b/devobsserver/script/ca.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+
+echo "HOSTNAME:"$HOSTNAME
+
+if [ ! -z "$1" ]
+then
+ outputfolder=$1
+else
+ outputfolder="/srv/obs/certs"
+fi
+
+if [ ! -e "$outputfolder" ]
+then
+ mkdir -p $outputfolder
+fi
+
+if [ ! -z "$SSL_SUBJECT" ]
+then
+ subject=$SSL_SUBJECT
+else
+ subject="/CN="$HOSTNAME
+fi
+
+cd $outputfolder
+
+if [ -e server.pem ]
+then
+ exit
+fi
+
+echo "Certs start!!!"
+echo $subject
+touch .rnd
+export RANDFILE=.rnd
+
+openssl genrsa -out server.key 1024
+
+echo "openssl req -subj "$subject" -new -key server.key -out server.csr"
+openssl req -subj "$subject" -new -key server.key -out server.csr
+
+echo "openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt"
+openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
+
+echo "copy server.pem to /etc/ssl/certs"
+cat server.key server.crt > server.pem
+
+cp server.pem /etc/ssl/certs/
+
+c_rehash /etc/ssl/certs/
+
+echo "Certs end!!!"
diff --git a/devobsserver/script/db.sh b/devobsserver/script/db.sh
new file mode 100755
index 0000000..bdf6806
--- /dev/null
+++ b/devobsserver/script/db.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+set -e
+
+if [ ! -e "/var/lib/mysql/$MYSQL_API_DATABASE/users.frm" ]
+then
+ echo "webui , api DB Rake~~~~start"
+ RAILS_ENV="production" rake -f /srv/www/obs/webui/Rakefile db:setup
+ RAILS_ENV="production" rake -f /srv/www/obs/api/Rakefile db:setup
+ echo "webui , api DB Rake~~~~end"
+fi
+#
diff --git a/devobsserver/script/initdb.sh b/devobsserver/script/initdb.sh
new file mode 100755
index 0000000..1ec2e5d
--- /dev/null
+++ b/devobsserver/script/initdb.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+set -e
+
+echo "initdb.sh start"
+
+if [[ ! -d $MYSQL_DATA_DIR_DEFAULT/$MYSQL_API_DATABASE ]]; then
+ if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
+ echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
+ echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
+ exit 1
+ fi
+
+ /usr/sbin/rcmysql start
+ # Allow some time for the service to start
+ sleep 5
+
+ echo "create database start"
+
+ echo "change root password"
+ mysql -u root <<-EOFMYSQL
+ DELETE FROM mysql.user ;
+ CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
+ GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
+ DROP DATABASE IF EXISTS test ;
+ CREATE DATABASE IF NOT EXISTS $MYSQL_API_DATABASE ;
+ CREATE DATABASE IF NOT EXISTS $MYSQL_WEBUI_DATABASE ;
+ CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;
+ CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD' ;
+ GRANT ALL ON $MYSQL_API_DATABASE.* TO '$MYSQL_USER'@'%','$MYSQL_USER'@'localhost' ;
+ GRANT ALL ON $MYSQL_WEBUI_DATABASE.* TO '$MYSQL_USER'@'%','$MYSQL_USER'@'localhost' ;
+ FLUSH PRIVILEGES ;
+ EOFMYSQL
+ echo "create database end"
+ /usr/sbin/rcmysql stop
+ # Allow some time for the service to start
+ sleep 5
+fi
+
+chown -R mysql:mysql /var/lib/mysql
+
+echo "initdb.sh end"
diff --git a/devobsserver/script/obsservice.sh b/devobsserver/script/obsservice.sh
new file mode 100755
index 0000000..1a3cd99
--- /dev/null
+++ b/devobsserver/script/obsservice.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+status () {
+ echo "---> ${@}" >&2
+}
+
+##[program:rcobsrepserver]
+/usr/sbin/rcobsrepserver start
+status "rcobsrepserver start"
+#sleep 1
+##[program:rcobssrcserver]
+/usr/sbin/rcobssrcserver start
+status "rcobssrcserver start"
+#sleep 1
+##[program:rcobsscheduler]
+/usr/sbin/rcobsscheduler start
+status "rcobsscheduler start"
+#sleep 1
+##[program:rcobsdispatcher]
+/usr/sbin/rcobsdispatcher start
+status "rcobsdispatcher start"
+#sleep 1
+##[program:rcobspublisher]
+/usr/sbin/rcobspublisher start
+status "rcobspublisher start"
+#sleep 1
+##[program:rcobsapidelayed]
+/usr/sbin/rcobsapidelayed start
+status "rcobsapidelayed start"
+#sleep 1
+##[program:rcobsservice]
+/usr/sbin/rcobsservice start
+status "rcobsservice start"
+#sleep 1
+
+chown -R wwwrun:www /srv/www/obs/api/log/
+chown -R wwwrun:www /srv/www/obs/webui/log/
diff --git a/devobsserver/script/repos.sh b/devobsserver/script/repos.sh
new file mode 100755
index 0000000..2d3ae3d
--- /dev/null
+++ b/devobsserver/script/repos.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+
+status () {
+ echo "---> ${@}" >&2
+}
+
+if [ ! -e /srv/obs/docker_bootstrapped ]; then
+ if [ ! -z "$1" ];then
+ reposfolder=$1
+ else
+ reposfolder="/srv/obs/repos"
+ fi
+
+ if [ ! -e "$reposfolder" ];then
+ mkdir -p $reposfolder
+ fi
+
+ status "chown for first run"
+ chown -R obsrun:obsrun /srv/obs/
+ chown -R wwwrun:www /srv/www/obs/api/
+ chown -R wwwrun:www /srv/www/obs/webui/
+
+ touch /srv/obs/docker_bootstrapped
+else
+ status "found docker_bootstrapped"
+fi
diff --git a/devobsserver/script/restart_obs.sh b/devobsserver/script/restart_obs.sh
new file mode 100755
index 0000000..8439454
--- /dev/null
+++ b/devobsserver/script/restart_obs.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+status () {
+ echo "---> ${@}" >&2
+}
+
+rcapache2 stop
+status "rcapache2 stop"
+rcobsapidelayed stop
+status "rcobsapidelayed stop"
+rcobspublisher stop
+status "rcobspublisher stop"
+rcobsdispatcher stop
+status "rcobsdispatcher stop"
+rcobsscheduler stop
+status "rcobsscheduler stop"
+rcobssrcserver stop
+status "rcobssrcserver stop"
+rcobsrepserver stop
+status "rcobsrepserver stop"
+rcobsservice stop
+status "rcobsservice stop"
+rcobswarden stop
+status "rcobswarden stop"
+rcmysql stop
+status "rcmysql stop"
+
+sleep 5
+
+rcmysql start
+status "rcmysql start"
+rcobswarden start
+status "rcobswarden start"
+rcobsservice start
+status "rcobsservice start"
+rcobsrepserver start
+status "rcobsrepserver start"
+rcobssrcserver start
+status "rcobssrcserver start"
+rcobsscheduler start
+status "rcobsscheduler start"
+rcobsdispatcher start
+status "rcobsdispatcher start"
+rcobspublisher start
+status "rcobspublisher start"
+rcapache2 start
+status "rcapache2 start"
+rcobsapidelayed start
+status "rcobsapidelayed start"
diff --git a/devobsserver/script/rsync.sh b/devobsserver/script/rsync.sh
new file mode 100755
index 0000000..5b8a402
--- /dev/null
+++ b/devobsserver/script/rsync.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -x
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+### ADD PERMISSION TO KVM ####
+RSYNC_HOST_ALLOWS=${RSYNC_HOST_ALLOWS:-*}
+
+[ -f /etc/rsyncd.conf ] || cat <<EOF > /etc/rsyncd.conf
+gid = nobody
+read only = true
+use chroot = true
+transfer logging = false
+log format = %h %o %f %l %b
+log file = /var/log/rsyncd.log
+#pid file = /var/run/rsyncd.pid
+slp refresh = 300
+use slp = false
+
+[_build_R_]
+ path = /srv/obs/build
+ comment = "get build log to directory"
+ uid = obsrun
+ gid = obsrun
+ read only = true
+ use chroot = true
+ hosts allow = ${RSYNC_HOST_ALLOWS}
+ list = false
+ incoming chmod = a=r,D+x
+EOF
+
+
+
+
diff --git a/devobsserver/script/startup.sh b/devobsserver/script/startup.sh
new file mode 100755
index 0000000..dcb4fce
--- /dev/null
+++ b/devobsserver/script/startup.sh
@@ -0,0 +1,32 @@
+#!/bin/bash -x
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+
+# init database
+/srv/script/initdb.sh
+
+#generate SSL CA
+/srv/script/ca.sh
+
+#generate repos folder
+/srv/script/repos.sh
+
+#rake db
+/srv/script/db.sh
+
+#rsync
+/srv/script/rsync.sh
+
+# start daemon
+/usr/bin/supervisord -n