Bash脚本更新ssl.conf中SSL证书文件的路径(RegEx单词与#匹配) [英] Bash script to update path to SSL certificate file in ssl.conf (RegEx word match with #)
问题描述
我正在创建一个可重用的脚本,用于自动在服务器设置上设置新SSL.我有几行需要更新文件路径.
I am creating a reusable script for automating the setup of new SSLs on server setups. I have a few different lines that need to get the file paths updated.
ssl.conf文件中的默认值看起来像这样(带有#号标记):
The defaults in the ssl.conf file look like this (Has leading # tag):
#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
我需要在bash脚本中对其进行动态设置,以使其最终像这样:
I need it to be dynamically set in the bash script, to end up like this:
SSLCACertificateFile /etc/pki/tls/certs/example-ca-bundle.crt
到目前为止,我是从这个开始的,但是我不确定自己在做什么.
So far I started out with this, but i'm not sure what I'm doing.
~/update_ssl_conf.sh
代码:
#!/bin/bash
SSL_CONFIG_PATH="/etc/httpd/conf.d/ssl.conf"
SSL_DEFAULT_CA_CERT_PATH="#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt"
SSL_CA_CERT_PATH="SSLCACertificateFile /etc/pki/tls/certs/example-ca-bundle.crt"
我尝试从下面链接的可接受的解决方案开始,然后在\ b之后添加#.
I tried starting with the accepted solution linked below, and adding in a # after \b.
(.*#)
match the comment(SSLCACertificateFile)
match the field name(.*)
match the value
在新路径后面仅需输入字段名称(第2组\2
)
Only the field name (group 2 \2
) is required following by your new path
这篇关于Bash脚本更新ssl.conf中SSL证书文件的路径(RegEx单词与#匹配)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!