Project

General

Profile

« Previous | Next » 

Revision 9cc2bdee

Added by Vincent MEMBRÉ almost 7 years ago

Fixes #10843: Rename technique editor hooks to have a better way to organize them and create reload hook

View differences:

rudder-webapp/SOURCES/post.write_technique.10_commit.sh
#!/bin/bash
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# 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 3.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
#
# That hook is designed to be run just after a technique was created or modified.
# Its goal is to commit the newly created technique with ncf-api to configuration-repository
#
set -e
STEP="Script start"
anomaly_handler() {
echo ""
echo "ERROR: An error happened in $0 during the step: ${STEP}"
}
trap anomaly_handler ERR INT TERM
# Variables
DESTINATION_PATH=${1}
TECHNIQUE=${2}
# Main
## Set necessary umask to prevent permission issues (mode 770)
umask 007
## Operate on configuration-repository's git tree
cd /var/rudder/configuration-repository
## Commit the new Technique
STEP="Commiting technique \"${TECHNIQUE}\""
git add "ncf/50_techniques/${TECHNIQUE}"
git commit --allow-empty -q -m "Commit ncf Technique \"${TECHNIQUE}\" in Rudder"
rudder-webapp/SOURCES/post.write_technique.50_rudderify.sh
#!/bin/bash
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# 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 3.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
set -e
STEP="Script start"
anomaly_handler() {
echo ""
echo "ERROR: An error happened in $0 during the step: ${STEP}"
}
trap anomaly_handler ERR INT TERM
#
# That hook is designed to be run just after a technique wwas created or modified
# It generates techniques files usable by Rudder, commit them in Tehcniques folder and reload the technique library
#
# Variables
DESTINATION_PATH="${1}"
TECHNIQUE="${2}"
CATEGORY_PATH='ncf_techniques/category.xml'
# Main
## Set necessary umask to prevent permission issues (mode 770)
umask 007
## Rudderify the new Technique
STEP="Creating rudder technique \"${TECHNIQUE}\" from ncf technique"
/usr/share/ncf/tools/ncf_rudder.py rudderify_technique /var/rudder/configuration-repository/techniques/ncf_techniques "${TECHNIQUE}"
## Operate on configuration-repository's git tree, in the Techniques
STEP="Commiting rudder technique \"${TECHNIQUE}\" to configuration-repository's git tree"
cd /var/rudder/configuration-repository/techniques/
# If a non-zero file exists on the filesystem...
if [ -s "${CATEGORY_PATH}" ]; then
#... and is not already added in git, add it
# grep return an error if do not find the value, so pipe to true to prevent being trapped
HANDLED_BY_GIT=$(git ls-tree -r master --name-only | grep -c "${CATEGORY_PATH}" || true)
if [ "${HANDLED_BY_GIT}" -eq 0 ];then
git add ncf_techniques/category.xml
fi
fi
## Commit the new Technique
git add "ncf_techniques/${TECHNIQUE}"
git commit --allow-empty -q -m "Commit meta Technique ${TECHNIQUE}"
rudder-webapp/SOURCES/post.write_technique.90_reload.sh
#!/bin/bash
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# 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 3.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
set -e
STEP="Script start"
anomaly_handler() {
echo ""
echo "ERROR: An error happened in $0 during the step: ${STEP}"
}
trap anomaly_handler ERR INT TERM
#
# That hook is designed to be run just after a technique wwas created or modified
# It generates techniques files usable by Rudder, commit them in Tehcniques folder and reload the technique library
#
# Variables
DESTINATION_PATH="${1}"
TECHNIQUE="${2}"
# Main
## Set necessary umask to prevent permission issues (mode 770)
umask 007
# Reload technique library, bypass the ssl verification since we are on localhost
STEP="Reloading the Techniques using Rudder API. Please reload them manually using Rudder web interface."
curl --proxy '' -s -f "http://localhost:8080/rudder/api/techniqueLibrary/reload"
rudder-webapp/SOURCES/post.write_technique.commit.sh
#!/bin/bash
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# 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 3.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
#
# That hook is designed to be run just after a technique was created or modified.
# Its goal is to commit the newly created technique with ncf-api to configuration-repository
#
set -e
STEP="Script start"
anomaly_handler() {
echo ""
echo "ERROR: An error happened in $0 during the step: ${STEP}"
}
trap anomaly_handler ERR INT TERM
# Variables
DESTINATION_PATH=${1}
TECHNIQUE=${2}
# Main
## Set necessary umask to prevent permission issues (mode 770)
umask 007
## Operate on configuration-repository's git tree
cd /var/rudder/configuration-repository
## Commit the new Technique
STEP="Commiting technique \"${TECHNIQUE}\""
git add "ncf/50_techniques/${TECHNIQUE}"
git commit --allow-empty -q -m "Commit ncf Technique \"${TECHNIQUE}\" in Rudder"
rudder-webapp/SOURCES/post.write_technique.rudderify.sh
#!/bin/bash
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# 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 3.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
set -e
STEP="Script start"
anomaly_handler() {
echo ""
echo "ERROR: An error happened in $0 during the step: ${STEP}"
}
trap anomaly_handler ERR INT TERM
#
# That hook is designed to be run just after a technique wwas created or modified
# It generates techniques files usable by Rudder, commit them in Tehcniques folder and reload the technique library
#
# Variables
DESTINATION_PATH="${1}"
TECHNIQUE="${2}"
CATEGORY_PATH='ncf_techniques/category.xml'
# Main
## Set necessary umask to prevent permission issues (mode 770)
umask 007
## Rudderify the new Technique
STEP="Creating rudder technique \"${TECHNIQUE}\" from ncf technique"
/usr/share/ncf/tools/ncf_rudder.py rudderify_technique /var/rudder/configuration-repository/techniques/ncf_techniques "${TECHNIQUE}"
## Operate on configuration-repository's git tree, in the Techniques
STEP="Commiting rudder technique \"${TECHNIQUE}\" to configuration-repository's git tree"
cd /var/rudder/configuration-repository/techniques/
# If a non-zero file exists on the filesystem...
if [ -s "${CATEGORY_PATH}" ]; then
#... and is not already added in git, add it
# grep return an error if do not find the value, so pipe to true to prevent being trapped
HANDLED_BY_GIT=$(git ls-tree -r master --name-only | grep -c "${CATEGORY_PATH}" || true)
if [ "${HANDLED_BY_GIT}" -eq 0 ];then
git add ncf_techniques/category.xml
fi
fi
## Commit the new Technique
git add "ncf_techniques/${TECHNIQUE}"
git commit --allow-empty -q -m "Commit meta Technique ${TECHNIQUE}"
# Reload technique library, bypass the ssl verification since we are on localhost
STEP="Reloading the Techniques using Rudder API. Please reload them manually using Rudder web interface."
curl --proxy '' -s -f "http://localhost:8080/rudder/api/techniqueLibrary/reload"
rudder-webapp/SOURCES/rudder-upgrade
chmod -R o-rwx ${CONFIGURATION_REPOSITORY}/ncf/50_techniques/
fi
# 4.2.0: Rename hooks to have a better ordering of hooks
CURRENT="$(pwd)"
cd ${CONFIGURATION_REPOSITORY}/ncf
for hook_file in commit.sh rudderify.sh; do
hook=ncf-hooks.d/post.write_technique.${hook_file}
if [ -f ${hook} ]; then
git ls-files --error-unmatch ${hook} >/dev/null 2>&1
MANAGED_BY_GIT=$?
if [ ${MANAGED_BY_GIT} -eq 0 ]; then
git rm ${hook}
git commit -m "Remove technique editor hook \"${hook}\""
else
rm ${hook}
fi
fi
done
cd ${CURRENT}
# all, started from 4.2.0: Commit new hooks
CURRENT="$(pwd)"
cd ${CONFIGURATION_REPOSITORY}/ncf
for hook_file in 10_commit.sh 50_rudderify.sh 90_reload.sh; do
hook=ncf-hooks.d/post.write_technique.${hook_file}
if [ -f ${hook} ]; then
git add ${hook}
git commit -m "Update technique editor hook \"${hook}\"" --allow-empty
fi
done
cd ${CURRENT}
}
# 3.2.0: Call rudderify on all local ncf techniques to make sure the promises will be properly generated
rudder-webapp/SPECS/rudder-webapp.spec
Source12: rudder-root-rename
Source13: rudder-passwords.conf
Source14: rudder-plugin
Source15: post.write_technique.commit.sh
Source16: post.write_technique.rudderify.sh
Source15: post.write_technique.10_commit.sh
Source16: post.write_technique.50_rudderify.sh
Source17: rudder-metrics-reporting
Source18: ca-bundle.crt
Source19: rudder-reload-cf-serverd
......
Source26: rudder-apache-webapp-ssl.conf
Source27: rudder-apache-webapp-nossl.conf
Source28: rudder-webapp.fc
Source29: post.write_technique.99_reload.sh
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
......
install -m 755 %{SOURCE15} %{buildroot}%{ruddervardir}/configuration-repository/ncf/ncf-hooks.d/
install -m 755 %{SOURCE16} %{buildroot}%{ruddervardir}/configuration-repository/ncf/ncf-hooks.d/
install -m 755 %{SOURCE29} %{buildroot}%{ruddervardir}/configuration-repository/ncf/ncf-hooks.d/
# Add rudder-metrics-reporting
cp %{SOURCE17} %{buildroot}%{rudderdir}/bin/
rudder-webapp/debian/rules
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder-passwords.conf /opt/rudder/etc/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder-webapp /opt/rudder/etc/server-roles.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder-web /opt/rudder/etc/server-roles.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ post.write_technique.rudderify.sh /var/rudder/configuration-repository/ncf/ncf-hooks.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ post.write_technique.commit.sh /var/rudder/configuration-repository/ncf/ncf-hooks.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ post.write_technique.10_commit.sh /var/rudder/configuration-repository/ncf/ncf-hooks.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ post.write_technique.50_rudderify.sh /var/rudder/configuration-repository/ncf/ncf-hooks.d/
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ post.write_technique.99_reload.sh /var/rudder/configuration-repository/ncf/ncf-hooks.d/
# Install upgrade tools and migration scripts

Also available in: Unified diff