mirror of
https://github.com/openappsec/attachment.git
synced 2025-09-30 11:44:29 +03:00
Adding packaging option to attachemnt
This commit is contained in:
8
nodes/nginx_attachment/CMakeLists.txt
Normal file
8
nodes/nginx_attachment/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
install(FILES install-nginx-attachment.sh DESTINATION nginx_attachment/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ)
|
||||
|
||||
gen_package(
|
||||
install-cp-nano-nginx-attachment.sh
|
||||
nginx_attachment
|
||||
./install-nginx-attachment.sh
|
||||
Check Point Attachment Registration Manager Nano Service Version ${PACKAGE_VERSION} Install Package
|
||||
)
|
117
nodes/nginx_attachment/install-nginx-attachment.sh
Executable file
117
nodes/nginx_attachment/install-nginx-attachment.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Attachment Detials
|
||||
ATTACHMENT_NAME="NGINX Attachemnt"
|
||||
ATTACHMENT_BIN_NAME="cp-nano-nginx-attachment"
|
||||
|
||||
#Const variables
|
||||
FORCE_STDOUT=true
|
||||
INSTALLATION_TIME=$(date)
|
||||
CP_NANO_LOG_PATH="/var/log/nano_agent"
|
||||
INSTALLATION_LOG_FILE=${CP_NANO_LOG_PATH}/${ATTACHMENT_BIN_NAME}-install.log
|
||||
|
||||
mkdir -p ${CP_NANO_LOG_PATH}
|
||||
|
||||
cp_print()
|
||||
{
|
||||
var_text=$1
|
||||
var_std_out=$2
|
||||
touch $INSTALLATION_LOG_FILE
|
||||
if [ -n "$var_std_out" ]; then
|
||||
if [ "$var_std_out" = "true" ]; then
|
||||
printf "%b\n" "$var_text"
|
||||
fi
|
||||
fi
|
||||
printf "%b\n" "$var_text" >> $INSTALLATION_LOG_FILE
|
||||
}
|
||||
|
||||
cp_exec()
|
||||
{
|
||||
var_cmd=$1
|
||||
var_std_out=$2
|
||||
# Send exec output to RES
|
||||
RES=$($var_cmd 2>&1)
|
||||
if [ -n "$RES" ]; then
|
||||
cp_print "$RES" "$var_std_out"
|
||||
fi
|
||||
}
|
||||
|
||||
run_installation()
|
||||
{
|
||||
cp_print "Starting installation of Check Point ${NANO_SERVICE_NAME} Nano service [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
|
||||
cp_exec "cp lib/libosrc_compression_utils.so /usr/lib/libosrc_compression_utils.so"
|
||||
cp_exec "cp lib/libosrc_compression_utils.so /usr/lib64/libosrc_compression_utils.so"
|
||||
cp_exec "cp lib/libosrc_nginx_attachment_util.so /usr/lib/libosrc_nginx_attachment_util.so"
|
||||
cp_exec "cp lib/libosrc_nginx_attachment_util.so /usr/lib64/libosrc_nginx_attachment_util.so"
|
||||
cp_exec "cp lib/libosrc_shmem_ipc.so /usr/lib/libosrc_shmem_ipc.so"
|
||||
cp_exec "cp lib/libosrc_shmem_ipc.so /usr/lib64/libosrc_shmem_ipc.so"
|
||||
cp_exec "cp lib/libngx_module.so /usr/lib/nginx/modules/ngx_cp_attachment_module.so"
|
||||
cp_exec "cp lib/libngx_module.so /usr/lib64/nginx/modules/ngx_cp_attachment_module.so"
|
||||
|
||||
[ -f /etc/nginx/nginx.conf ] && sed -i 1i'load_module /usr/lib/nginx/modules/ngx_cp_attachment_module.so;' /etc/nginx/nginx.conf || echo
|
||||
[ -f /etc/nginx/template/nginx.tmpl ] && sed -i 1i'load_module /usr/lib/nginx/modules/ngx_cp_attachment_module.so;' /etc/nginx/template/nginx.tmpl || echo
|
||||
[ -f /usr/local/share/lua/5.1/kong/templates/nginx.lua ] && sed -i 's|return [[|return [[\\nload_module /usr/lib64/nginx/modules/ngx_cp_attachment_module.so;|g' /usr/local/share/lua/5.1/kong/templates/nginx.lua || echo
|
||||
[ -f /usr/local/share/lua/5.1/kong/templates/nginx.lua ] && sed -i 's|http {|http {\ncp_worker_processes ${{nginx_worker_processes}};|g' /usr/local/share/lua/5.1/kong/templates/nginx.lua || echo
|
||||
|
||||
cp_print "Installation completed successfully." $FORCE_STDOUT
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Check Point: available flags are"
|
||||
echo "--install : install ${NANO_SERVICE_NAME} Nano Service"
|
||||
echo "--uninstall : remove ${NANO_SERVICE_NAME} Nano Service"
|
||||
echo "--pre_install_test : run Pre-installation test for ${NANO_SERVICE_NAME} Nano Service install package"
|
||||
echo "--post_install_test : run Post-installation test for ${NANO_SERVICE_NAME} Nano Service install package"
|
||||
exit 255
|
||||
}
|
||||
|
||||
run_uninstall()
|
||||
{
|
||||
cp_print "Starting uninstallation of Check Point ${NANO_SERVICE_NAME} Nano service [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
|
||||
cp_print "Uninstallation completed successfully." $FORCE_STDOUT
|
||||
}
|
||||
|
||||
run_pre_install_test()
|
||||
{
|
||||
cp_print "Starting Pre-installation test of Check Point ${ATTACHMENT_NAME} installation package [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
|
||||
cp_print "Successfully finished pre-installation test for Check Point ${ATTACHMENT_NAME} installation package [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
run_post_install_test()
|
||||
{
|
||||
cp_print "Starting Post-installation test of Check Point ${ATTACHMENT_NAME} Nano service installation package [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
|
||||
cp_print "Successfully finished post-installation test for Check Point ${ATTACHMENT_NAME} Nano service installation package [$INSTALLATION_TIME]\n" $FORCE_STDOUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
if [ '--install' = "$1" ]; then
|
||||
run_installation "${@}"
|
||||
elif [ '--uninstall' = "$1" ]; then
|
||||
run_uninstall
|
||||
elif [ '--pre_install_test' = "$1" ]; then
|
||||
run_pre_install_test
|
||||
elif [ '--post_install_test' = "$1" ]; then
|
||||
run_post_install_test
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Administrative privileges required for this Package (use su or sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shift
|
||||
run "${@}"
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user