Bash를 사용하여 Apache 구성 스크립트 구성

Bash를 사용하여 Apache 구성 스크립트 구성

들여쓰기가 제대로 되지 않았지만 작동하는 구성 파일(가상 호스트)이 있다고 가정해 보겠습니다 www-example.com.conf. 예를 들면 다음과 같습니다.

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
ServerName www.example.com
ServerAlias example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/example.com/public
 DirectoryIndex index.php
<Directory /var/www/example.com/public>
AllowOverride All
Options +FollowSymLinks +Indexes
Order Allow,Deny
Allow from all
</Directory>




    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/example-com-error.log
    CustomLog ${APACHE_LOG_DIR}/example-com-access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

원하는 출력은 다음과 같습니다.

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName www.example.com
    ServerAlias example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/example.com/public
    DirectoryIndex index.php

    <Directory /var/www/example.com/public>
        AllowOverride All
        Options +FollowSymLinks +Indexes
        Order Allow,Deny
        Allow from all
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/example-com-error.log
    CustomLog ${APACHE_LOG_DIR}/example-com-access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

tidy우리는 bash 스크립트에서 이 구성 파일의 들여쓰기를 "" 수정하고 싶습니다 (구성 파일을 손상시키지 않고).

이 작업을 수행하려면 어떤 명령줄 도구를 사용해야 합니까?

나는 시도했다:

  • xml_pp test.txt(''>''의 일부로 상단에 ''*:80>''이 있기 때문에 기술적으로 XML이 아니기 때문에 실패합니다)
  • 사용tidy

관련 정보