gh-106: Post install/upgrade package scrips

Closes #106
pull/108/head
Vlastimil Holer 7 years ago
parent ae70e77911
commit ff3551a834
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -82,10 +82,13 @@ fi
set -e set -e
BUILD_DIR=$(mktemp -d) BUILD_DIR=$(mktemp -d)
_POSTIN=$(mktemp) _POSTIN=$(mktemp)
_PREUN=$(mktemp) _PREUN=$(mktemp)
_POSTUN=$(mktemp)
_POSTUP=$(mktemp)
trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN}" EXIT trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN} ${_POSTUN} ${_POSTUP}" EXIT
while IFS= read -r -d $'\0' SRC; do while IFS= read -r -d $'\0' SRC; do
F_TAGS=${SRC##*##} F_TAGS=${SRC##*##}
@ -148,13 +151,23 @@ else
cat ${PREUN} >"${_PREUN}" cat ${PREUN} >"${_PREUN}"
fi fi
if [ -n "${POSTUN}" ]; then
cat ${POSTUN} >"${_POSTUN}"
fi
if [ -n "${POSTUP}" ]; then
cat ${POSTUP} >"${_POSTUP}"
fi
fpm --name "${NAME}" --version "${VERSION}" --iteration "${RELEASE_FULL}" \ fpm --name "${NAME}" --version "${VERSION}" --iteration "${RELEASE_FULL}" \
--architecture all --license "${LICENSE}" \ --architecture all --license "${LICENSE}" \
--vendor "${VENDOR}" --maintainer "${MAINTAINER}" \ --vendor "${VENDOR}" --maintainer "${MAINTAINER}" \
--description "${DESCRIPTION}" --url "${URL}" \ --description "${DESCRIPTION}" --url "${URL}" \
--output-type "${TYPE}" --input-type dir --chdir "${BUILD_DIR}" \ --output-type "${TYPE}" --input-type dir --chdir "${BUILD_DIR}" \
${POSTIN:+ --after-install ${_POSTIN}} \ ${POSTIN:+ --after-install ${_POSTIN}} \
${POSTUP:+ --after-upgrade ${_POSTUP}} \
${PREUN:+ --before-remove ${_PREUN}} \ ${PREUN:+ --before-remove ${_PREUN}} \
${POSTUN:+ --after-remove ${_POSTUN}} \
--rpm-os linux \ --rpm-os linux \
--rpm-summary "${SUMMARY}" \ --rpm-summary "${SUMMARY}" \
${DEPENDS:+ --depends ${DEPENDS// / --depends }} \ ${DEPENDS:+ --depends ${DEPENDS// / --depends }} \

@ -1,21 +1,5 @@
#!/bin/bash #!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
NETWORK=${NETWORK:-yes} NETWORK=${NETWORK:-yes}
NETWORK_EC2=${NETWORK_EC2:-no} NETWORK_EC2=${NETWORK_EC2:-no}
SERVICES=${SERVICES:-one-context-local one-context} SERVICES=${SERVICES:-one-context-local one-context}
@ -31,8 +15,10 @@ if which systemctl >/dev/null 2>&1 && \
[ -d /etc/systemd ] && \ [ -d /etc/systemd ] && \
[ -f /usr/lib/systemd/system/one-context.service ]; [ -f /usr/lib/systemd/system/one-context.service ];
then then
systemctl daemon-reload >/dev/null 2>&1 || :
for S in ${SERVICES}; do for S in ${SERVICES}; do
systemctl enable "${S}.service" systemctl enable "${S}.service" >/dev/null 2>&1
done done
fi fi

@ -0,0 +1,4 @@
#!/bin/bash
NETWORK_EC2=yes
SERVICES='one-context'

@ -0,0 +1,7 @@
#!/bin/bash
udevadm control --reload >/dev/null 2>&1 || :
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then
systemctl daemon-reload >/dev/null 2>&1 || :
fi

@ -0,0 +1,7 @@
#!/bin/bash
udevadm control --reload >/dev/null 2>&1 || :
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then
systemctl daemon-reload >/dev/null 2>&1 || :
fi

@ -0,0 +1,27 @@
#!/bin/bash
SERVICES=${SERVICES:-one-context one-context-local}
# Disable services
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then
for S in ${SERVICES}; do
systemctl --no-reload disable "${S}.service" >/dev/null 2>&1 || :
systemctl stop "${S}.service" >/dev/null 2>&1 || :
done
fi
if which chkconfig >/dev/null 2>&1; then
for S in ${SERVICES}; do
chkconfig --del "${S}" >/dev/null 2>&1 || :
done
elif which update-rc.d >/dev/null 2>&1; then
for S in ${SERVICES}; do
update-rc.d -f "${S}" remove >/dev/null 2>&1 || :
done
elif which rc-update >/dev/null 2>&1; then
for S in ${SERVICES}; do
rc-update del "${S}" boot >/dev/null 2>&1 || :
done
fi

@ -0,0 +1,3 @@
#!/bin/bash
SERVICES='one-context'

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
NETWORK_EC2=yes
SERVICES='one-context'

@ -1,44 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SERVICES=${SERVICES:-one-context one-context-local}
# Disable services
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then
for S in ${SERVICES}; do
systemctl --no-reload disable "${S}.service" >/dev/null 2>&1 || :
done
systemctl daemon-reload >/dev/null 2>&1 || :
fi
if which chkconfig >/dev/null 2>&1; then
for S in ${SERVICES}; do
chkconfig --del "${S}" >/dev/null 2>&1 || :
done
elif which update-rc.d >/dev/null 2>&1; then
for S in ${SERVICES}; do
update-rc.d -f "${S}" remove >/dev/null 2>&1 || :
done
elif which rc-update >/dev/null 2>&1; then
for S in ${SERVICES}; do
rc-update del "${S}" boot >/dev/null 2>&1 || :
done
fi

@ -1,19 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SERVICES='one-context'

@ -8,8 +8,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall} POSTIN=${POSTINST:-pkg/postinstall}
PREUN=${PREUN:-preuninstall} PREUN=${PREUN:-pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
@ -22,8 +24,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context} CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall} POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall} PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'el7') 'el7')
@ -35,8 +39,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall} POSTIN=${POSTINST:-pkg/postinstall}
PREUN=${PREUN:-preuninstall} PREUN=${PREUN:-pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'el7_ec2') 'el7_ec2')
@ -48,8 +54,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context} CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall} POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall} PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'suse') 'suse')
@ -61,8 +69,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init cloud-init-config-suse} REPLACES=${REPLACES:-cloud-init cloud-init-config-suse}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall} POSTIN=${POSTINST:-pkg/postinstall}
PREUN=${PREUN:-preuninstall} PREUN=${PREUN:-pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'suse_ec2') 'suse_ec2')
@ -74,8 +84,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init cloud-init-config-suse} REPLACES=${REPLACES:-cloud-init cloud-init-config-suse}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context} CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall} POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall} PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
@ -88,8 +100,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall} POSTIN=${POSTINST:-pkg/postinstall}
PREUN=${PREUN:-preuninstall} PREUN=${PREUN:-pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'deb_ec2') 'deb_ec2')
@ -101,8 +115,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init} REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context} CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall} POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall} PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-pkg/postupgrade}
;; ;;
'alpine') 'alpine')
@ -114,8 +130,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-} #not respected REPLACES=${REPLACES:-} #not respected
CONFLICTS=${CONFLICTS:-one-context-ec2} CONFLICTS=${CONFLICTS:-one-context-ec2}
POSTIN=${POSTINST:-postinstall} POSTIN=${POSTINST:-pkg/postinstall}
PREUN=${PREUN:-preuninstall} PREUN=${PREUN:-pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-} # FPM 1.9.3 bug: https://github.com/jordansissel/fpm/blob/v1.9.3/lib/fpm/package/apk.rb#L149
;; ;;
'alpine_ec2') 'alpine_ec2')
@ -127,8 +145,10 @@ case "${TARGET}" in
PROVIDES=${PROVIDES:-} PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-} #not respected REPLACES=${REPLACES:-} #not respected
CONFLICTS=${CONFLICTS:-one-context} CONFLICTS=${CONFLICTS:-one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall} POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall} PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall}
POSTUN=${POSTUN:-pkg/postuninstall}
POSTUP=${POSTUP:-} # FPM 1.9.3 bug: https://github.com/jordansissel/fpm/blob/v1.9.3/lib/fpm/package/apk.rb#L149
;; ;;
'iso') 'iso')

Loading…
Cancel
Save