Download and insert salt string inside wordpress wp-config.php with Bash

前端 未结 10 2284
有刺的猬
有刺的猬 2021-02-13 06:27

How can I insert the content of the variable $SALT in a specific point (line or string) of a file like wp-contet.php from wordpress using Bash script?



        
10条回答
  •  终归单人心
    2021-02-13 06:51

    This version defines new keys if none exist, and also replaces existing keys:

    #!/bin/bash
    find . -name wp-config.php -print | while read line
    do 
        curl http://api.wordpress.org/secret-key/1.1/salt/ > wp_keys.txt
        sed -i.bak -e '/put your unique phrase here/d' -e \
        '/AUTH_KEY/d' -e '/SECURE_AUTH_KEY/d' -e '/LOGGED_IN_KEY/d' -e '/NONCE_KEY/d' -e \
        '/AUTH_SALT/d' -e '/SECURE_AUTH_SALT/d' -e '/LOGGED_IN_SALT/d' -e '/NONCE_SALT/d' $line
        cat wp_keys.txt >> $line
        rm wp_keys.txt
    done
    

提交回复
热议问题