Skip to content

Instantly share code, notes, and snippets.

@ari
Created July 16, 2015 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ari/01eaae67d8c941ccaf68 to your computer and use it in GitHub Desktop.
Save ari/01eaae67d8c941ccaf68 to your computer and use it in GitHub Desktop.
Create onCourse package script
{
"name": "onCourseServer",
"version": "__version__",
"origin": "misc/onCourseServer",
"comment": "ish onCourse Server for FreeBSD",
"arch": "freebsd:9:x86:64",
"www": "http://www.ish.com.au",
"maintainer": "support@ish.com.au",
"prefix": "/usr/local",
"licenselogic": "single",
"licenses": [
"Proprietary"
],
"flatsize": 52633295,
"desc": "onCourse Server",
"categories": [
"java",
"misc"
],
"users": [
"oncourse"
],
"groups": [
"oncourse"
],
"deps": {
"javavmwrapper": {
"origin": "java/javavmwrapper",
"version": "2.5"
}
},
"files": {
"/usr/local/etc/rc.d/onCourseServer": "__rchash__",
"/usr/local/onCourse/server-__version__-all.jar": "__jarhash__"
},
"directories": {
"/usr/local/onCourse": "y"
},
"scripts": {
"pre-install": "echo \"\"; echo \"===> Creating users and/or groups.\"; if ! /usr/sbin/pw groupshow oncourse >/dev/null 2>&1; then; echo \"Creating group 'oncourse' with gid '823'.\"; /usr/sbin/pw groupadd oncourse -g 823\nelse echo \"Using existing group 'oncourse'.\"; fi; if ! /usr/sbin/pw usershow oncourse >/dev/null 2>&1; then echo \"Creating user 'oncourse' with uid '823'.\"; /usr/sbin/pw useradd oncourse -u 823 -g 823 -c \"onCourse\" -d /usr/local/oncourse -s /usr/sbin/nologin; else echo \"Using existing user 'oncourse'.\";",
"pre-deinstall": "if /usr/sbin/pw usershow oncourse >/dev/null 2>&1; then echo \"==> You should manually remove the \"oncourse\" user. \"; fi"
}
root_dir=${tmp}/${version_number}
# Nice clean new directory
rm -rf ${root_dir}
mkdir ${root_dir}
mkdir -p ${root_dir}/usr/local/onCourse
mkdir -p ${root_dir}/usr/local/etc/rc.d
# Copy startup script
cp "${templates_path}/onCourseServer.template" ${root_dir}/usr/local/etc/rc.d/onCourseServer
# Copy manifest
cp "${templates_path}/+MANIFEST.template" ${root_dir}/+MANIFEST
# Replace some placeholders
rchash=$(sha256 ${oc_rcscript})
jarhash=$(sha256 ${oc_jarfile})
sed -i '' "s,__version__,${version_number}," ${root_dir}/+MANIFEST
sed -i '' "s,__version__,${version_number}," ${root_dir}/usr/local/etc/rc.d/onCourseServer
sed -i '' "s,__rchash__,${rchash}," ${root_dir}/+MANIFEST
sed -i '' "s,__jarhash__,${jarhash}," ${root_dir}/+MANIFEST
cd ${root_dir}/usr/local/onCourse
file_to_extract=$(tar -tf ${tar_file} |grep server)
echo "===> Extracting ${file_to_extract} from ${tar_file}"
tar xfz ${tar_file} ${file_to_extract} &> /dev/null
# Create the package
echo "===> Creating pkg file ${oc_pkg_name}"
pkg create -r "${root_dir}" -m "${root_dir}" -o ${artifacts_path}/${version_number}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment