EventHooks not working

Hi

I’m sorry if the answer is obvious or if I have misunderstood anything about eventhooks, but the eventhooks does not appear to work for me.

I downloaded the sample hooks file here: http://interworx.com/iworx-hooks.conf and installed it here /etc/iworx-hooks.conf then enabled EventHooks from Nodeworx plugins.

I copied the new siteworx eventhook to notify when a new siteworx account was created as detailed by http://forums.interworx.com/showthread.php?5146-Custom-SiteWorx-Client-Mail

I completed the following on notify_sw_client.sh, chmod 0770 /usr/local/bin/notify_sw_client.sh and chown iworx /usr/local/bin/notify_sw_client.sh

I created a new test siteworx account, and no email was received (I used my email address).

I then thought the iworx-hooks.conf might be the issue, so I disabled Eventhooks from nodeworx plugins, and completed the following on iworx-hooks.conf, chmod 0770 /etc/iworx-hooks.conf and chown iworx /etc/iworx-hooks.conf

After re-enabling the EventHooks plugin, I created a different new test siteworx account and still no email was received.#

For clarification, here is the iworx-hooks.conf I have, the notify_sw_client.sh is exactly as Iworx-Matt script.

Sample hooks file content

Comments start with pound

Empty lines are fine

Non-empty lines have a minimum of 3 components: Controller, Action, and Script + optional parameters

NOTE 1: This file must be readable by the ‘iworx’ user

and your custom scripts must be executable by the iworx user.

They will run as the ‘iworx’ user, not as root.

NOTE 2: Form variables for the hooked events will be available to your script

as environment variables, prefixed with ‘iw_’

run my script after a siteworx account gets added

#Ctrl_Nodeworx_Siteworx add /myscripts/siteworx-account.sh
Ctrl_Nodeworx_Siteworx add /usr/local/bin/notify_sw_client.sh

run with the --delete parameter after a siteworx account gets deleted

#Ctrl_Nodeworx_Siteworx delete /myscripts/siteworx-account.sh --delete

run my pointer-added.sh script

#Ctrl_Siteworx_DomainsPointer add /usr/local/bin/pointer-added.sh

We use our own mail servers and no trace could be found of any email connections.

Please could I ask if someone could let me know where I have gone wrong, or if I need to open a support a ticket.

Many thanks

John

I seconded this problem.
Looking at the /home/interworx/var/log/iworx.log


2013-07-27 09:25:26.47455 [ts9omg-wcn5-ktnu-WEB] [INFO]  : hook prog not executable by iworx: /usr/local/bin/enable_session_save_path.sh : /xhr.php 
2013-07-27 09:25:26.69654 [ts9omg-fvt4-rk7m-PHP] [INFO]  :  139.228.32.134 routing: Ctrl_Nodeworx_Siteworx -> searchCommit : /xhr.php 

Did you get to fix yours?

Hi

I’m sorry NO, not yet, but I have not had much time and so far no one has responded either.

My error is different to yours, and I think you might not have applied the permissions to the hook as it states iworx denied, so you would be better applying the permissions as detailed in my thread above.

My error extracts are as follows, and it’s on a centos6 64 bit system.

iworx log
: plugin hook exited non-zero: /usr/local/bin/notify_sw_client.sh: : /xhr.php
2013-07-17 08:27:09.73763 [ez1t4k-s4r4-yzud-PHP] [INFO] :
error log
/usr/local/bin/notify_sw_client.sh: line 15: syntax error: unexpected end of file,

I hope the permissions help you

Many thanks

John

Hi John,

Thank you for sharing. Are you running interworx for hosting business or internal operations?
I am running Interworx 5 beta 6 on CloudLinux 6.4, hoping to start a hosting business, but need to play around during this trial period to make sure the Softaculous works, all while looking on how to get the WHMCS online as well.

I followed the instruction here: http://forums.interworx.com/showthread.php?3187-Auto-user-specific-php.ini-for-suPHP
On the last couple post from Matt.

Here is my permissions:

/etc/iworx-hooks.conf:


-rwxrwx--- 1 iworx root 942 Jul 27 19:22 iworx-hooks.conf

/usr/local/bin:


-rwxr-xr-x 1 iworx iworx 1840 Jul 27 15:59 enable_save_session_path.sh

Also added the visudo as required:


## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
Cmnd_Alias CAGEFS_CMDS = /usr/sbin/cagefsctl, /bin/ps, /bin/grep, /sbin/service
iworx ALL=NOPASSWD: CAGEFS_CMDS
Defaults:iworx !requiretty

# This is as per Matt - Interworx, seems different than above.
%iworx ALL=(ALL) NOPASSWD:SETENV: /bin/bash -p /usr/local/bin/enable_session_save_path.sh
Defaults:%iworx !requiretty

Hi

I think your on the wrong topic sorry.

I’ve reread your message and I believe you need this topic on the forum.

http://forums.interworx.com/showthread.php?t=3187

I also consider your issue is permission based as your error states not executable by iWorx and if so, have completed the permission instructions.

When posting it is a good idea to include your os version as there are different Linux you can use.

I hope that helps you to resolve your issue.

Many thanks

John

Hi

I believe your issue is a permission based issue, as your log states the following:

hook prog not executable by iworx

Once you correct this, you will know if you have any further errors in the hook.

I would advice you check, or redo the permissions it states as follows:

Ensure that both this file and the Event Hook config are both readable

and executable by the iworx user:

chmod 0770 /usr/local/bin/enable_session_save_path.sh

chown iworx /usr/local/bin/enable_session_save_path.sh

In order for this script to run successfully, the iworx user

must be added to the sudoers file. This can be done as follows:

Run ‘visudo’

Append these lines:

%iworx ALL=(ALL) NOPASSWD:SETENV: /bin/bash -p /usr/local/bin/enable_session_save_path.sh

Defaults:%iworx !requiretty

Save and exit visudo

If it still shows the same error, I would advice a server restart to be sure it is clear and retest once more.

I hope that helps you

Many thanks

John

[QUOTE=d2d4j;21762]
My error extracts are as follows, and it’s on a centos6 64 bit system.

iworx log
: plugin hook exited non-zero: /usr/local/bin/notify_sw_client.sh: : /xhr.php
2013-07-17 08:27:09.73763 [ez1t4k-s4r4-yzud-PHP] [INFO] :
error log
/usr/local/bin/notify_sw_client.sh: line 15: syntax error: unexpected end of file,[/QUOTE]

Hi,

Your problem is maybe caused by a malformed line in the file. Can you paste your /usr/local/bin/notify_sw_client.sh file her in a new post? So i can take a loo what’s the problem.

Hi Vrnagy

Many thanks, it’s much appreciated.

Please find the current notify_dw_client.sh as follows:

if [[ “$iw_master_domain” == “” ]]; then
exit 1
fi
mail -s ‘Welcome to SiteWorx!’ $iw_email – -f admin@example.com<<EOF
Hello! Your SiteWorx account for $iw_master_domain has just been created.
To login, visit https://$iw_master_domain:2443/siteworx
E-mail: $iw_email
Password: $iw_password
EOF
exit 0

Please find the full notify_dw_client.sh as detailed in http://forums.interworx.com/showthre…rx-Client-Mail

#!/bin/bash

INSTALLATION:

Install this script at /usr/local/bin/notify_sw_client.sh

Enable the Event Hooks plugin in NodeWorx.

Add the following line to your InterWorx Event Hook Configuration:

Ctrl_Nodeworx_Siteworx add /usr/local/bin/notify_sw_client.sh

Ensure that both this file and the Event Hook config are both readable

and executable by the iworx user:

chmod 0770 /usr/local/bin/notify_sw_client.sh

chown iworx /usr/local/bin/notify_sw_client.sh

if [[ “$iw_master_domain” == “” ]]; then
exit 1
fi
mail -s ‘Welcome to SiteWorx!’ $iw_email – -f admin@example.com<<EOF
Hello! Your SiteWorx account for $iw_master_domain has just been created.
To login, visit https://$iw_master_domain:2443/siteworx
E-mail: $iw_email
Password: $iw_password
EOF
exit 0

Any help is appreciated and both the cut down version and the full version of the code does not work. All permission were applied.

Lastly, the server is a centos 64 bit with all patches applied, and running current stable version of interworx, version 4.11.7-483

Many thanks

John

Hi,

Try this:

#!/bin/bash
#
# INSTALLATION:
#
# Install this script at /usr/local/bin/notify_sw_client.sh
# 
# Enable the Event Hooks plugin in NodeWorx.
# Add the following line to your InterWorx Event Hook Configuration:
# 
# Ctrl_Nodeworx_Siteworx add /usr/local/bin/notify_sw_client.sh
# 
# Ensure that both this file *and* the Event Hook config are both readable
# and executable by the iworx user:
# 
# chmod 0770 /usr/local/bin/notify_sw_client.sh
# chown iworx /usr/local/bin/notify_sw_client.sh
if [[ "$iw_master_domain" == "" ]]; then
  exit 1
fi

mail -s 'Welcome to SiteWorx!' -S from=admin@example.com  $iw_email <<EOF
Hello! Your SiteWorx account for $iw_master_domain has just been created.
To login, visit https://$iw_master_domain:2443/siteworx
E-mail: $iw_email
Password: $iw_password
EOF
exit 0

Or You can run a simple test version from it with the following:

#!/bin/bash
#
# INSTALLATION:
#
# Install this script at /usr/local/bin/notify_sw_client.sh
# 
# Enable the Event Hooks plugin in NodeWorx.
# Add the following line to your InterWorx Event Hook Configuration:
# 
# Ctrl_Nodeworx_Siteworx add /usr/local/bin/notify_sw_client.sh
# 
# Ensure that both this file *and* the Event Hook config are both readable
# and executable by the iworx user:
# 
# chmod 0770 /usr/local/bin/notify_sw_client.sh
# chown iworx /usr/local/bin/notify_sw_client.sh

iw_master_domain=your_domain
iw_email=your_address@domain.com
iw_password=test


if [[ "$iw_master_domain" == "" ]]; then
  exit 1
fi

mail -s 'Welcome to SiteWorx!' -S from=admin@example.com  $iw_email <<EOF
Hello! Your SiteWorx account for $iw_master_domain has just been created.
To login, visit https://$iw_master_domain:2443/siteworx
E-mail: $iw_email
Password: $iw_password
EOF
exit 0

then run: bash /usr/local/bin/notify_sw_client.sh

Hi

Sorry I mistyped sw as dw.

It should read as sw and not dw

Sorry for that and any confusion it may have caused.

Many thanks

John

Hi

I have partially resolved my issue but I am a little stuck on exiting non zero, and I cant see why it should abort.

Please see snapshots of the bash script run manually, and also the notify_sw_client.sh as seen from vi (I originally made the file using notepad and uploaded it, which caused the initial error, silly mistake I know).

Please could someone let me know if I have made an error anywhere or perhaps why it is aborting.

IWORX.LOG

: script end : package.activate.php
2013-08-06 05:45:27.01822 [w2q8aq-a4wo-goml-WEB] [INFO] : plugin hook exited non-zero: /usr/local/bin/notify_sw_client.sh: : /xhr.php
2013-08-06 05:45:27.03561 [w2q8aq-a4wo-83ao-PHP] [INFO] :

Many thanks

John

Hi,

One reply from yesterday awaits moderation so i make a reply for the last message. The non zero exit is only made when no $iw_master_domain avaiable in the script.
Right before the first if statement insert a new line with the following content:

export > /your/home/test.log

This will save all variables to a file and you can investigate if one of them are missing. If you want, you can paste it to here (don’t paste the password variable), so we can help :slight_smile:

Hi Vrnagy

Many thanks for your help, it is appreciated.

Please see the log file, and the password does not matter, it is not a real domain we have, and it has been deleted.

Any pointers is appreciated.

Many thanks

John

export CONTENT_LENGTH=“1519”
export CONTENT_TYPE=“application/x-www-form-urlencoded”
export DOCUMENT_ROOT="/home/interworx/html"
export GATEWAY_INTERFACE=“CGI/1.1”
export HTTPS=“on”
export HTTP_ACCEPT="/"
export HTTP_ACCEPT_ENCODING=“gzip, deflate”
export HTTP_ACCEPT_LANGUAGE=“en-GB”
export HTTP_CACHE_CONTROL=“no-cache”
export HTTP_CONNECTION=“Keep-Alive”
export HTTP_COOKIE=“service-status-toggle=1; server-info-toggle=1; server-at-a-glance-toggle=1; account-info-toggle=1; webmail-choice=horde; interworx-cp=ffb221de9baff9d659d61937747d6530; iw-menu-nodeworx=10”
export HTTP_DNT=“1”
export HTTP_HOST=“sentmail.co.uk:2443
export HTTP_REFERER=“https://sentmail.co.uk:2443/nodeworx/siteworx
export HTTP_USER_AGENT=“Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)”
export HTTP_X_REQUESTED_WITH=“XMLHttpRequest”
export IWLOG_REQUEST_ID=“a1hg”
export IWLOG_SESSION_ID=“bdc41k”
export LANG=“en_US.UTF-8”
export OLDPWD
export PATH="/bin:/usr/bin:/usr/local/bin"
export PHPRC="/home/interworx/etc"
export PWD="/usr/local/interworx/html"
export QUERY_STRING=""
export REDIRECT_HTTPS=“on”
export REDIRECT_SSL_CIPHER=“AES128-SHA”
export REDIRECT_SSL_CIPHER_ALGKEYSIZE=“128”
export REDIRECT_SSL_CIPHER_EXPORT=“false”
export REDIRECT_SSL_CIPHER_USEKEYSIZE=“128”
export REDIRECT_SSL_CLIENT_CERT=""
export REDIRECT_SSL_CLIENT_VERIFY=“NONE”
export REDIRECT_SSL_COMPRESS_METHOD=“NULL”
export REDIRECT_SSL_PROTOCOL=“TLSv1”
export REDIRECT_SSL_SECURE_RENEG=“true”
export REDIRECT_SSL_SERVER_A_KEY=“rsaEncryption”
export REDIRECT_SSL_SERVER_A_SIG=“sha1WithRSAEncryption”
export REDIRECT_SSL_SERVER_CERT="**** DELETED FOR SECURITY -----
"
export REDIRECT_SSL_SERVER_I_DN="/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certificates.godaddy.com/repository/CN=Go Daddy Secure Certification Authority/serialNumber=07969287"
export REDIRECT_SSL_SERVER_I_DN_C=“US”
export REDIRECT_SSL_SERVER_I_DN_CN=“Go Daddy Secure Certification Authority”
export REDIRECT_SSL_SERVER_I_DN_L=“Scottsdale”
export REDIRECT_SSL_SERVER_I_DN_O=“GoDaddy.com, Inc.”
export REDIRECT_SSL_SERVER_I_DN_OU=“http://certificates.godaddy.com/repository
export REDIRECT_SSL_SERVER_I_DN_ST=“Arizona”
export REDIRECT_SSL_SERVER_M_SERIAL=“03F1B733F794AB”
export REDIRECT_SSL_SERVER_M_VERSION=“3”
export REDIRECT_SSL_SERVER_S_DN="/OU=Domain Control Validated/CN=sentmail.co.uk"
export REDIRECT_SSL_SERVER_S_DN_CN=“sentmail.co.uk
export REDIRECT_SSL_SERVER_S_DN_OU=“Domain Control Validated”
export REDIRECT_SSL_SERVER_V_END=“Aug 3 18:13:42 2014 GMT”
export REDIRECT_SSL_SERVER_V_START=“Aug 3 18:18:18 2013 GMT”
export REDIRECT_SSL_SESSION_ID=“3F2DE3479546308A4A75AE31CFB364C089DBBAA635EB1AE0396668A987F7D827”
export REDIRECT_SSL_TLS_SNI=“sentmail.co.uk
export REDIRECT_SSL_VERSION_INTERFACE=“mod_ssl/2.2.23”
export REDIRECT_SSL_VERSION_LIBRARY=“OpenSSL/1.0.0-fips”
export REDIRECT_STATUS=“200”
export REDIRECT_URL="/xhr.php"
export REDIRECT_downgrade_1_0=“1”
export REDIRECT_force_response_1_0=“1”
export REDIRECT_ssl_unclean_shutdown=“1”
export REMOTE_ADDR=“81.134.75.105”
export REMOTE_PORT=“2960”
export REQUEST_METHOD=“POST”
export REQUEST_URI="/xhr.php"
export SCRIPT_FILENAME="/home/interworx/html/index.php"
export SCRIPT_NAME="/index.php"
export SERVER_ADDR=“84.234.26.239”
export SERVER_ADMIN="[no address given]"
export SERVER_NAME=“sentmail.co.uk
export SERVER_PORT=“2443”
export SERVER_PROTOCOL=“HTTP/1.1”
export SERVER_SIGNATURE=""
export SERVER_SOFTWARE=“Apache”
export SHLVL=“2”
export SSL_CIPHER=“AES128-SHA”
export SSL_CIPHER_ALGKEYSIZE=“128”
export SSL_CIPHER_EXPORT=“false”
export SSL_CIPHER_USEKEYSIZE=“128”
export SSL_CLIENT_CERT=""
export SSL_CLIENT_VERIFY=“NONE”
export SSL_COMPRESS_METHOD=“NULL”
export SSL_PROTOCOL=“TLSv1”
export SSL_SECURE_RENEG=“true”
export SSL_SERVER_A_KEY=“rsaEncryption”
export SSL_SERVER_A_SIG=“sha1WithRSAEncryption”
export SSL_SERVER_CERT="
DELETED FOR SECURITY ****-
"
export SSL_SERVER_I_DN="/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certificates.godaddy.com/repository/CN=Go Daddy Secure Certification Authority/serialNumber=07969287"
export SSL_SERVER_I_DN_C=“US”
export SSL_SERVER_I_DN_CN=“Go Daddy Secure Certification Authority”
export SSL_SERVER_I_DN_L=“Scottsdale”
export SSL_SERVER_I_DN_O=“GoDaddy.com, Inc.”
export SSL_SERVER_I_DN_OU=“http://certificates.godaddy.com/repository
export SSL_SERVER_I_DN_ST=“Arizona”
export SSL_SERVER_M_SERIAL=“03F1B733F794AB”
export SSL_SERVER_M_VERSION=“3”
export SSL_SERVER_S_DN="/OU=Domain Control Validated/CN=sentmail.co.uk"
export SSL_SERVER_S_DN_CN=“sentmail.co.uk
export SSL_SERVER_S_DN_OU=“Domain Control Validated”
export SSL_SERVER_V_END=“Aug 3 18:13:42 2014 GMT”
export SSL_SERVER_V_START=“Aug 3 18:18:18 2013 GMT”
export SSL_SESSION_ID=“3F2DE3479546308A4A75AE31CFB364C089DBBAA635EB1AE0396668A987F7D827”
export SSL_TLS_SNI=“sentmail.co.uk
export SSL_VERSION_INTERFACE=“mod_ssl/2.2.23”
export SSL_VERSION_LIBRARY=“OpenSSL/1.0.0-fips”
export _="/usr/local/bin/notify_sw_client.sh"
export downgrade_1_0=“1”
export force_response_1_0=“1”
export iw_OPT_BACKUP=“1”
export iw_OPT_BANDWIDTH=“1000”
export iw_OPT_BURSTABLE=“1”
export iw_OPT_CGI_ACCESS=“1”
export iw_OPT_CRONTAB=“1”
export iw_OPT_DNS_RECORDS=“1”
export iw_OPT_EMAIL_ALIASES=“999999999”
export iw_OPT_EMAIL_AUTORESPONDERS=“999999999”
export iw_OPT_EMAIL_BOXES=“999999999”
export iw_OPT_EMAIL_GROUPS=“999999999”
export iw_OPT_FTP_ACCOUNTS=“999999999”
export iw_OPT_MYSQL_DBS=“999999999”
export iw_OPT_MYSQL_DB_USERS=“999999999”
export iw_OPT_POINTER_DOMAINS=“999999999”
export iw_OPT_RESOLVE_XFERLOG_DNS=“1”
export iw_OPT_SAVE_XFER_LOGS=“1”
export iw_OPT_SLAVE_DOMAINS=“999999999”
export iw_OPT_SSL=“1”
export iw_OPT_STORAGE=“100”
export iw_OPT_SUBDOMAINS=“999999999”
export iw_action=“addCommit”
export iw_billing_day=“1”
export iw_confirm_password=“IslesHollyMurkyJinn59”
export iw_create_package=""
export iw_database_server=“localhost”
export iw_domain=“anydomain.net
export iw_domainname=“anydomain.net
export iw_email=“john@doc2disk.com
export iw_ipaddr=“84.234.26.239”
export iw_ipaddress=“84.234.26.239”
export iw_language=“en-us”
export iw_menu_style=“small”
export iw_new_package_name=""
export iw_nickname=“dd”
export iw_options=“100,1000,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,1,1,1,1,1,1,1,1”
export iw_package_name=“single”
export iw_packagetemplate=“single”
export iw_password=“IslesHollyMurkyJinn59”
export iw_password1=“IslesHollyMurkyJinn59”
export iw_password2=“IslesHollyMurkyJinn59”
export iw_reseller=“1”
export iw_reseller_label=“Server Admin (john@doc2disk.com)”
export iw_security_token=“PvhtIUS0EIOnDvIIxmPJwMfGtsoE”
export iw_simplescripts=“1”
export iw_softaculous=“1”
export iw_status=“pending”
export iw_theme=“coolfreshness”
export iw_uniqname=“anydomai”
export ssl_unclean_shutdown=“1”

Hi,

well, we got the problem. There is no iw_master_domain variable avaiable, but iw_domain and iw_domainname. Try to replace $iw_master_domain with $iw_domain in the script, and run again. I think this should help.

Hi

You are 100% correct and I thank you.

As soon as I changed the variable it worked lovely.

I am somewhat confused why the variable was not correctly shown by interworx but I am still learning.

Once again many thanks for help and quick reply.

John

Hi,

You’re welcome :slight_smile:

Maybe the iw_master_domain only exists in v5 and not in v4.

Hi

Yes good point and I’m sorry I never thought of that.

When I’m back later today I’ll post the full script for v4 here, in case other users have the same issue.

I do have 1 small issue remaining though in that the email sent displays the EOF exit 0 in its body. I don’t suppose you know why.

Once again many thanks

John

On vim screenshot thereis two > char after the closing EOF so your script looks like
EOF>>
exit 0

simply replace with:
EOF
exit 0

Hi

Many thanks, I’ll try that but interestingly, when I created the hook using vim, it was vim that put those additions in, and my unexpected end of file error disappeared.

I’m sorry to have taken so much off your time and thank you

John

Hi

I am pleased to let everyone know that this now works lovely, and special thanks to vrnagy for their help.

Please find the hook for Version 4 of interworx, for email notification when a new account is created. Please also note that we have changed it slightly, so it only emails the siteworx email address.

I would advise anyone creating this hook to do so using vi or vim, I have found that using notepad can cause an issue.

Many thanks

John

#!/bin/bash

INSTALLATION:

Install this script at /usr/local/bin/notify_sw_client.sh

Enable the Event Hooks plugin in NodeWorx.

Add the following line to your InterWorx Event Hook Configuration:

Ctrl_Nodeworx_Siteworx add /usr/local/bin/notify_sw_client.sh

Ensure that both this file and the Event Hook config are both readable

and executable by the iworx user:

chmod 0770 /usr/local/bin/notify_sw_client.sh

chown iworx /usr/local/bin/notify_sw_client.sh

if [[ “$iw_domain” == “” ]]; then
exit 1
fi

mail -s ‘Welcome to SiteWorx!’ $iw_email<<EOF
Hello! Your SiteWorx account for $iw_domain has just been created.

To login, visit https://$iw_domain:2443/siteworx

E-mail: $iw_email
Password: $iw_password

EOF
exit 0