1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice

Event Manager and script

Discussion in 'Plesk for Linux - 8.x and Older' started by MaRiOs, Aug 23, 2005.

  1. MaRiOs

    MaRiOs Guest

    0
     
    I use the Event manager ,and
    add an Event handler.

    The hander is about Domain Creation
    and it is supposed to create a folder .ssh every time a new domain is added.The command it runs is :

    /usr/local/psa/bin/ssh.sh <new_domain_name>

    the ssh.sh script contains :

    #!/bin/bash
    echo "--------------" >> /tmp/event_handler.log
    /bin/date >> /tmp/event_handler.log
    /usr/bin/id >> /tmp/event_handler.log
    cd /home/httpd/vhosts/$1 >> /tmp/event_handler.log
    pwd >> /tmp/event_handler.log
    if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; fi >> /tmp/event_handler.log
    #mkdir .ssh >> /tmp/event_handler.log
    echo "domain: $1" >> /tmp/event_handler.log # domain name`cat authorized_keys`
    echo "--------------" >> /tmp/event_handler.log
    echo -e "Subject:New Domain Notification\nFrom:Server <non-reply@tophost.gr>\n"`cat /tmp/event_handler.log` | /usr/sbin/sendmail m.maravelias@tophost.gr

    In the email i get result like :

    Tue Aug 23 07:03:35 CEST 2005 uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) /root domain: sdgfadgfsadfgsdfgsd.gr --------------

    the .ssh folder is not created in the target folder i wanted,so i gave the
    pwd >> /tmp/event_handler.log in the script to see where it goes.
    and it goes in the /root
    I tried many things and i cant make it go to cd /home/httpd/vhosts/$1
    any ideas ?
     
  2. jamesyeeoc

    jamesyeeoc Guest

    0
     
    I emailed you. You have to set it up in Event Manager for 'Physical Hosting created', not 'Domain Created', or what happens is your script is run BEFORE the new domain directories are created.
     
  3. MaRiOs

    MaRiOs Guest

    0
     
    it worked! thank you!
     
  4. jamesyeeoc

    jamesyeeoc Guest

    0
     
    No problem, send me a couple bottles of the good Ouzo :D
     
  5. MaRiOs

    MaRiOs Guest

    0
     
    dont be happy its not finished yet i have to add some more things,
    im testing them now,
    ill be back with questions lol
     
  6. jamesyeeoc

    jamesyeeoc Guest

    0
     
    Understood and expected. That's what these forums are for!
     
  7. MaRiOs

    MaRiOs Guest

    0
     
    Ok no questions for this part ;)

    The final script looks like that :

    #!/bin/bash
    echo "--------------" >> /tmp/event_handler.log
    /bin/date >> /tmp/event_handler.log # information on the event date and time
    /usr/bin/id >> /tmp/event_handler.log # information on the user, on behalf of which the script was executed (to ensure control)
    cd /home/httpd/vhosts/$1 >> /tmp/event_handler.log
    pwd >> /tmp/event_handler.log
    if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; chown $2 .ssh ; chgrp psaserv .ssh ; fi >> /tmp/event_handler.log
    cd /home/httpd/vhosts/$1/cgi-bin >> /tmp/event_handler.log
    if [ ! -d locked ]; then mkdir locked ; chmod 755 locked ; chown $2 locked ; chgrp psaserv locked ; fi >> /tmp/event_handler.log
    echo "domain: $1" >> /tmp/event_handler.log # information on the created client account
    echo "login: $2" >> /tmp/event_handler.log # information on the created client account
    echo "--------------" >> /tmp/event_handler.log
    echo -e "Subject:New Domain Notification\nFrom:Server <non-reply@tophost.gr>\n"`cat /tmp/event_handler.log` | /usr/sbin/sendmail m.maravelias@tophost.gr


    I have added this <new_system_user>
    in the handler and a new line in the script
    so now it creates the .ssh folder gives it the chown chmod chgrp i want
    and then do the same for the locked folder :)

    mission accomplished.
     
Loading...