-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added make_rpmPackage.sh to build RPM packages automatically
Updated red5.spec for 1.0.3-release
- Loading branch information
Showing
5 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
VERSION= | ||
SOURCE0=red5-server-$(VERSION)-RELEASE-server.tar.gz | ||
SOURCE1=red5.init | ||
SPEC=red5.spec | ||
TOPDIR=$(shell pwd) | ||
|
||
prepare: $(SPEC) | ||
mkdir -p BUILD SOURCES SPECS SRPMS RPMS | ||
cp $(SOURCE0) SOURCES | ||
cp $(SOURCE1) SOURCES | ||
cp $(SPEC) SPECS | ||
sed -i 's;@VERSION@;$(VERSION);' SPECS/$(SPEC) | ||
|
||
build: prepare | ||
rpmbuild -ba --nodeps --define '_topdir $(TOPDIR)' SPECS/$(SPEC) | ||
|
||
clean: | ||
rm -rf SOURCES SPECS RPMS SRPMS BUILD BUILDROOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Use make_rpmPackage.sh to build automatically. | ||
Run this script on RHEL or CentOS. | ||
You can find RPM packages in RPMS/SRPMS directroy after the script would run. | ||
|
||
NOTE: this script is only available for Red5 release version. | ||
|
||
1. Create RPM Packages | ||
|
||
Usage: | ||
|
||
$ ./make_rpmPackage.sh -h | ||
Usage: ./make_rpmPackage.sh [OPTION] red5_version | ||
|
||
red5_version is like this | ||
- 1.0.x | ||
- 1.0.3 | ||
- 1.0.2 | ||
|
||
Options: | ||
-h, --help | ||
|
||
* To build 1.0.3-release, like this | ||
|
||
$ ./make_rpmPackage.sh 1.0.3 | ||
$ tree RPMS/ SRPMS/ | ||
RPMS/ | ||
└── x86_64 | ||
├── red5-1.0.3-1.el7.centos.x86_64.rpm | ||
└── red5-debuginfo-1.0.3-1.el7.centos.x86_64.rpm | ||
SRPMS/ | ||
└── red5-1.0.3-1.el7.centos.src.rpm | ||
|
||
You can confirm make_rpmPackage.log if failed. | ||
|
||
|
||
2. Install binary RPM and JDK | ||
|
||
$ sudo rpm -ivh RPMS/x86_64/red5-1.0.3-1.el7.centos.x86_64.rpm | ||
Preparing... ################################# [100%] | ||
Updating / installing... | ||
1:red5-1.0.3-1.el7.centos ################################# [100%] | ||
|
||
$ sudo vi /var/lib/red5/conf/logback.xml | ||
--- logback.xml.orig 2014-12-15 17:36:20.000000000 +0900 | ||
+++ logback.xml 2014-12-15 12:41:59.985638644 +0900 | ||
@@ -9,7 +9,7 @@ | ||
<appender class="ch.qos.logback.core.FileAppender" name="FILE"> | ||
- <File>log/red5.log</File> | ||
+ <File>/var/lib/red5/log/red5.log</File> | ||
<Append>false</Append> | ||
<encoder> | ||
|
||
* download JDK and deploy it | ||
e.g) red5-1.0.3 requires JDK7 and deploy to /opt/jdk/jdk1.7.0_71 | ||
|
||
$ sudo vi /etc/init.d/red5 | ||
--- red5.orig 2014-12-15 17:36:21.000000000 +0900 | ||
+++ red5 2014-12-15 17:49:22.459399002 +0900 | ||
@@ -8,7 +8,7 @@ | ||
-export JAVA_HOME= | ||
+export JAVA_HOME=/opt/jdk/jdk1.7.0_71 | ||
if [ -z "$JAVA_HOME" ]; then | ||
|
||
$ sudo service red5 start | ||
Starting red5: [ OK ] | ||
|
||
$ sudo service red5 status | ||
Running red5 (pid 2492) ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
#!/bin/bash -- | ||
|
||
# default configuration | ||
DATE=$(date +"%Y-%m-%d %H:%M:%S") | ||
PROG_NAME=$(basename $0) | ||
LOG_FILE="$(pwd)/$(echo ${PROG_NAME} | sed "s/\.sh//").log" | ||
|
||
# archive repositories for installing files | ||
GITHUB_URL="https://github.com" | ||
|
||
SERVER_VERSION= | ||
SERVER_URL="$GITHUB_URL/Red5/red5-server" | ||
SERVER_DOWNLOAD_URL="$SERVER_URL/releases/download/v\${version}-RELEASE/" | ||
SERVER_ARCHIVE_NAME="red5-server-\${version}-RELEASE-server.tar.gz" | ||
|
||
# requires | ||
NEEDED_COMMANDS=( | ||
"curl" | ||
"make" | ||
"rpmbuild" | ||
) | ||
|
||
# for error check | ||
RET_OK=0 | ||
RET_ERROR=1 | ||
|
||
|
||
####################################################################### | ||
# Utilities | ||
####################################################################### | ||
log() { | ||
local date=$(date +"%Y-%m-%d %H:%M:%S") | ||
echo -e "$date - INFO : $*" | tee -a $LOG_FILE | ||
} | ||
|
||
error() { # color red | ||
local date=$(date +"%Y-%m-%d %H:%M:%S") | ||
echo -en "\e[31m" | ||
echo -e "$date - ERROR: $*" | tee -a $LOG_FILE | ||
echo -en "\e[m" | ||
} | ||
|
||
run_command() { | ||
local eval cmd="$*" | ||
log "$ $cmd" | ||
eval "$*" | tee -a $LOG_FILE | ||
} | ||
|
||
download() { | ||
local url="$1" | ||
local archive_name="$2" | ||
run_command "curl -# -L $url -o $archive_name" | ||
} | ||
|
||
####################################################################### | ||
# Functions | ||
####################################################################### | ||
get_red5_server_release() { | ||
LAST_FUNCNAME=$FUNCNAME | ||
local version="$1" | ||
local download_url=$(eval echo $SERVER_DOWNLOAD_URL) | ||
local archive_name=$(eval echo $SERVER_ARCHIVE_NAME) | ||
local url="${download_url}/${archive_name}" | ||
|
||
if [ -f $archive_name ]; then | ||
log "** $archive_name is found so never download" | ||
return $RET_OK | ||
fi | ||
|
||
log "** getting red5-server archive ..." | ||
download $url $archive_name | ||
[ ! -f $archive_name ] && return $RET_ERROR | ||
|
||
return $RET_OK | ||
} | ||
|
||
make_rpm_package() { | ||
LAST_FUNCNAME=$FUNCNAME | ||
local version="$1" | ||
log "** making rpm package ..." | ||
run_command "make clean" | ||
run_command "make VERSION=$version build" | ||
return $RET_OK | ||
} | ||
|
||
check_needed_commands() { | ||
LAST_FUNCNAME=$FUNCNAME | ||
local i= | ||
local cmd= | ||
local retval=$RET_OK | ||
|
||
log "* check commands this script uses" | ||
for ((i=0; i<${#NEEDED_COMMANDS[@]}; i++)) | ||
do | ||
cmd=${NEEDED_COMMANDS[$i]} | ||
which $cmd > /dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
error "** '$cmd' command is not found, need to install!" | ||
retval=$RET_ERROR | ||
else | ||
run_command "$cmd --version" | ||
fi | ||
done | ||
return $retval | ||
} | ||
|
||
check_argument() { | ||
LAST_FUNCNAME=$FUNCNAME | ||
|
||
# not implemented now ... | ||
[ $# -eq 0 ] && return $RET_ERROR | ||
return $RET_OK | ||
} | ||
|
||
check_error() { | ||
local retval=$1 | ||
[ $retval != $RET_OK ] && echo "Error in '$LAST_FUNCNAME' function" | ||
# not implemented now ... | ||
return $retval | ||
} | ||
|
||
usage() { | ||
echo "Usage: $0 [OPTION] red5_version" | ||
echo | ||
echo "red5_version is like this" | ||
echo " - 1.0.x" | ||
echo " - 1.0.3" | ||
echo " - 1.0.2" | ||
echo | ||
echo "Options:" | ||
echo " -h, --help" | ||
exit 0 | ||
} | ||
|
||
main() { | ||
LAST_FUNCNAME=$FUNCNAME | ||
local version="$1" | ||
[ -z "$version" ] && usage && return $RET_OK | ||
|
||
log "* Start $PROG_NAME on $DATE" | ||
|
||
# get red5-server release and build | ||
SERVER_VERSION=${version} | ||
log "** target version: $SERVER_VERSION" | ||
get_red5_server_release $SERVER_VERSION || return $? | ||
make_rpm_package $SERVER_VERSION || return $? | ||
|
||
log "* End $PROG_NAME on $DATE" | ||
return $RET_OK | ||
} | ||
|
||
|
||
####################################################################### | ||
# Run Main | ||
####################################################################### | ||
for OPT in "$@" | ||
do | ||
case "$OPT" in | ||
'-h'|'--help'|-*) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
rm -f $LOG_FILE | ||
check_needed_commands || exit $? | ||
check_argument "$@" || usage $? | ||
main "$@" || check_error $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#! /bin/sh | ||
|
||
# For RedHat and cousins: | ||
# chkconfig: 2345 85 85 | ||
# description: Red5 flash streaming server | ||
# processname: red5 | ||
|
||
# Source function library | ||
. /etc/rc.d/init.d/functions | ||
|
||
export JAVA_HOME= | ||
if [ -z "$JAVA_HOME" ]; then | ||
echo -n "need to set JAVA_HOME in red5.init" && failure | ||
echo | ||
exit 1 | ||
fi | ||
|
||
PROG=red5 | ||
if [ -z "$RED5_HOME" ]; then | ||
export RED5_HOME=/var/lib/red5 | ||
fi | ||
DAEMON=$RED5_HOME/$PROG.sh | ||
PIDFILE=/var/run/$PROG.pid | ||
|
||
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5 | ||
|
||
RETVAL=0 | ||
|
||
case "$1" in | ||
start) | ||
echo -n $"Starting $PROG: " | ||
$DAEMON >/dev/null 2>/dev/null & | ||
RETVAL=$? | ||
if [ $RETVAL -eq 0 ]; then | ||
echo $! > $PIDFILE | ||
touch /var/lock/subsys/$PROG | ||
fi | ||
[ $RETVAL -eq 0 ] && success $"$PROG startup" || failure $"$PROG startup" | ||
echo | ||
;; | ||
stop) | ||
echo -n $"Shutting down $PROG: " | ||
killproc -p $PIDFILE | ||
RETVAL=$? | ||
echo | ||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
status) | ||
status $PROG -p $PIDFILE | ||
RETVAL=$? | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|restart|status}" | ||
RETVAL=1 | ||
esac | ||
|
||
exit $RETVAL |
Oops, something went wrong.