Skip to content

Instantly share code, notes, and snippets.

@perfecto25
Last active September 25, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfecto25/169c2fedebbac74eab0d5b9a5f7a7a7c to your computer and use it in GitHub Desktop.
Save perfecto25/169c2fedebbac74eab0d5b9a5f7a7a7c to your computer and use it in GitHub Desktop.
Atlassian Jira RPM packager
#!/bin/bash
' This script packages atlassian Jira as an RPM
Prerequisites:
1. install Jira from .bin installer locally on the machine you are packaging from, choose Advanced Setup
configure install path, port, etc. Once install is complete, copy the $INSTALL_DIR/.install4j/response.varfile to
same directory where you are running this script from. This file is used for silent installs
2. Copy the Jira startup script to your /etc/init.d/ dir, name it "jira"
3. to create the Jira RPM, run this script ./pkg_jira.sh
4. FPM will generate the RPM and attempt to upload it to your Artifactory path
'
jira_version=7.5.0
jira_bin="atlassian-jira-software-${jira_version}-x64.bin"
jira_url="https://downloads.atlassian.com/software/jira/downloads/${jira_bin}"
artif_server="your_artif_url"
artif_port="8081"
artif_repo_path="rpms/a/atlassian/jira"
function check4error() {
if [ "$?" -ne 0 ]; then echo "${1} step failed"; exit 1; fi
}
if [ ! $(whoami) = "root" ]
then
echo "[ERROR] Not root! run this script as root"
exit 1
fi
# fix startup script if jira user is jira1
# caused by: https://confluence.atlassian.com/jirakb/how-to-set-the-user-jira-runs-as-in-linux-433390559.html
userdel jira
# check if FPM is installed and version 1.4
fpmver=$(gem list | grep fpm)
if [ ! "${fpmver}" == "fpm (1.8.1)" ]
then
echo "[ERROR] FPM is not installed here or not proper version, exiting"
exit 1
fi
# cleanup old RPMs
rm -f *.rpm
check4error "rm -f *.rpm"
# 1. get Jira bin from Atlassiany
[ -f $jira_bin ] || wget --no-check-certificate -P . $jira_url
# 2. install Jira via bin installer (using bin since tar installer lacks the JRE folder)
chmod +x $jira_bin
./$jira_bin -q -varfile response.varfile
check4error "install bin"
echo "CREATING JIRA SOFTWARE RPM"
/usr/local/bin/fpm -s dir -t rpm --workdir $(pwd) --verbose --description "Atlassian Jira" \
--architecture x86_64 --maintainer "Atlassian" --url "www.atlassian.com" --name atlassian-jira --rpm-init jira \
--version ${jira_version} /opt/atlassian/jira
check4error "fpm make new RPM"
rpm_name=$(ls *${jira_version}*.rpm)
[ -z $ARTIF_KEY ] && echo "Artifactory key env var ARTIF_KEY is not set, cannot upload RPM to Artifactory.. exiting" && exit 1;
#echo "----- get md5 checksum"
md5=$(md5sum $rpm_name | awk -F" " {'print $1'})
#echo "----- get sha1 checksum"
sha1=$(sha1sum $rpm_name | awk -F" " {'print $1'})
#echo "----- upload RPM to artifactory using API key"
curl -H "X-JFrog-Art-Api:${ARTIF_KEY}" -H "X-Checksum-Md5:${md5}" -H "X-Checksum-Sha1:${sha1}" -X PUT "http://${artif_server}:${artif_port}/artifactory/${artif_repo_path}/${rpm_name}" -T $rpm_name
# Cleanup
# uninstall bin from packager machine
/opt/atlassian/jira/uninstall -q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment