Skip to main content

Need help making a bash file for a plugin

Comments

5 comments

  • Jason84
    I changed the SSL.conf to only need this in it
    # /** # * @version 1.7.2 # * @package Engintron for cPanel/WHM # * @author Fotis Evangelou # * @url https://engintron.com # * @copyright Copyright (c) 2010 - 2016 Nuevvo Webware P.C. All rights reserved. # * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html # */ server { listen 443 ssl http2; server_name CHANGEME.com www.CHANGEME.com; ssl_certificate /var/cpanel/ssl/installed/certs/CHANGEMESSL.crt; ssl_certificate_key /var/cpanel/ssl/installed/keys/CHANGEMESSL.key; ssl_trusted_certificate /var/cpanel/ssl/installed/cabundles/CHANGEMESSL.cabundle; include ssl_proxy_params_common; }
    So that it can be small and easy to have the server make the SSL.conf file but i don't know how to get the server to automatically make the conf file when a new SSL is uploaded to a website or update a existing SSL.conf file with the new SSL stuff. Can anyone help me make a bash script that looks in the httpd.conf for the vhost that have SSL installed for the servername, SSL key, cert and cabundle information and it makes a SSL.conf for my nginx server?
    0
  • cPanelMichael
    Hello, I recommend browsing to the "Development" tab in "WHM >> Tweak Settings" and enabling the following option: Debug mode is on. The system displays information about every stage for every hookable event, even if no hooks exist for that stage. Then, perform the specific actions via cPanel or WHM that you'd like to monitor or hook into, and review /usr/local/cpanel/logs/error_log when doing so to get a better idea of which API functions you'd need to hook into. You can then review the following document for information on getting started with standardized hooks: Guide to Standardized Hooks - Software Development Kit - cPanel Documentation You can find a list of system administration services on the following URL if you'd like someone to develop the script for you: System Administration Services | cPanel Forums Thank you.
    0
  • Jason84
    That was not helpful and was not what i was looking for all i needed was a small bash script to look for the domains SSL info. I end up getting the script from someone off github that it will copy the key and cert info to it own folder to be used in my nginx server. I know it still needs work to make the ssl.conf file for my nginx this is a good start and i just have to finish editing the script so it adds the conf file to the nginx server.
    #!/bin/bash CHAINPATH='/etc/nginx/ssl/chain.pem'; CERTSPATH='/var/cpanel/ssl/installed/certs'; KEYSPATH='/var/cpanel/ssl/installed/keys'; CUSTOMCERTSPATH='/etc/nginx/ssl/certs'; CUSTOMKEYPATH='/etc/nginx/ssl/keys'; for domain in `ls $CERTSPATH/*.crt` do name=${domain#$CERTSPATH/}; fqdn=${name::-60}; key=${name::-48}; cp $KEYSPATH/${key#$fqdn'_'}_*.key $CUSTOMKEYPATH/$fqdn.key; awk NF $domain $CHAINPATH >> $CUSTOMCERTSPATH/$fqdn.crt; echo "ssl_certificate $CUSTOMCERTSPATH/$fqdn.crt;"; echo "ssl_certificate_key $CUSTOMKEYPATH/$fqdn.key;"; echo ""; done
    0
  • Jason84
    Can someone help me with my bash script please. I been working on this script to build a SSL.conf file for my nginx and also store a copy of the SSL key, cert and caboundle to it own folder. I want to change the "for" to look in the httpd.conf file for the ServerName, SSLCertificateFile, SSLCertificateKeyFile, and SSLCACertificateFile for the info and setting them to use their own variables like SAVERNAME, SSL1, SSL2 and SSL3 so they can be used to fill in the data that is needed. Right now the "for" only looks in the cPanel installed SSL folders to get the SSL stuff but i know there has to be a way where i can just read the httpd.conf file to pull the info i need to add it to my nginx ssl.conf file. Here is what i have so far and you will see the domain is missing because the SSL installed folders don't use the correct domain name like domain-name.com and it use a _ as a replacement for - and . So far everything is working on getting the SSL stuff and making a copy of the SSL files but i need the domain names.
    #!/bin/bash CHAINPATH='/etc/nginx/ssl/chain.pem'; CUSTOMCERTSPATH='/etc/nginx/ssl/certs'; CUSTOMKEYPATH='/etc/nginx/ssl/keys'; CERTSPATH='/var/cpanel/ssl/installed/certs'; KEYSPATH='/var/cpanel/ssl/installed/keys'; for domain in `ls $CERTSPATH/*.crt` do name=${domain#$CERTSPATH/}; fqdn=${name::-60}; key=${name::-48}; cp $KEYSPATH/${key#$fqdn'_'}_*.key $CUSTOMKEYPATH/$fqdn.key; awk NF $domain $CHAINPATH >> $CUSTOMCERTSPATH/$fqdn.crt; REMOVEWWW="${fqdn//www_/}"; GETTLD="${REMOVEWWW##*_}" FILEDATA=$"# /** # * @version 1.7.2 # * @package Engintron for cPanel/WHM # * @author Fotis Evangelou # * @url https://engintron.com # * @copyright Copyright (c) 2010 - 2016 Nuevvo Webware P.C. All rights reserved. # * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html # */ server { listen 443 ssl http2; server_name .$GETTLD www..$GETTLD; ssl_certificate $CUSTOMCERTSPATH/$fqdn.crt; ssl_certificate_key $CUSTOMKEYPATH/$fqdn.key; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /var/cpanel/ssl/installed/cabundles/COMODO_CA_Limited_dbe3e9376d3359020526b6bc3f725c0f_1865548799.cabundle; include ssl_proxy_params_common; }"; echo "$FILEDATA" > /etc/nginx/test/$REMOVEWWW.conf; done
    Here what i get when i do echo "$FILEDATA";
    # /** # * @version 1.7.2 # * @package Engintron for cPanel/WHM # * @author Fotis Evangelou # * @url https://engintron.com # * @copyright Copyright (c) 2010 - 2016 Nuevvo Webware P.C. All rights reserved. # * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html # */ server { listen 443 ssl http2; server_name .com www..com; ssl_certificate /etc/nginx/ssl/certs/www_world_war_event_com.crt; ssl_certificate_key /etc/nginx/ssl/keys/www_world_war_event_com.key; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /var/cpanel/ssl/installed/cabundles/COMODO_CA_Limited_dbe3e9376d3359020526b6bc3f725c0f_1865548799.cabundle; include ssl_proxy_params_common; }
    I know i can use
    awk '/<\/VirtualHost>|ServerName|SSLCertificateFile|SSLCertificateKeyFile|SSLCACertificateFile / ' /usr/local/apache/conf/httpd.conf|grep -v '';
    but i am not good at coding and learning as a go but when i run that code and use echo "$1"; it prints everything i don't know how to use it with a "for" and set the variables to be used. I hope someone can help me and can understand what i am trying to do.
    0
  • cPanelMichael
    Hello, We're happy to help provide you with references to API functions that you can implement in your script, or information about where specific data is stored, but help with the programming language itself isn't something we generally offer. You're likely to receive more user-feedback on coding practices on a website such as StackOverflow. You may also want to reach out to the plugin developer you are using for Nginx to see why it's not working for SSL. This thread may also help if you are interested in different Nginx plugins: Easyapache 4 + nginx Thank you.
    0

Please sign in to leave a comment.