0

このアドレスにWordPressのAPIサービスからコンテンツ全体を自動的にコピーし、既存の行を置き換えてwp-config.phpに貼り付けるスクリプトを作成しようとしています。

45: define('AUTH_KEY',         'put your unique phrase here');
46: define('SECURE_AUTH_KEY',  'put your unique phrase here');
47: define('LOGGED_IN_KEY',    'put your unique phrase here');
48: define('NONCE_KEY',        'put your unique phrase here');
49: define('AUTH_SALT',        'put your unique phrase here');
50: define('SECURE_AUTH_SALT', 'put your unique phrase here');
51: define('LOGGED_IN_SALT',   'put your unique phrase here');
52: define('NONCE_SALT',       'put your unique phrase here');

行くための最良の方法は何ですか?

4

1 に答える 1

0

arutaku さんが wget についてのヒントを教えてくれました。私はまだこの解決策が完璧だとは思っていません (以下で理由を説明します)。しかし、これはまだ有効なオプションです。だから、私のスクリプト:

    # Delete lines from 45 to 52 from wp-config.php 
    sed -i 45,52d wp-config.php
    # Get new lines and save them in a temporary file
    curl https://api.wordpress.org/secret-key/1.1/salt/ > temp-salt
    # Insert temporary file content into wp-config.php after line 44
    sed -i '44r temp-salt' wp-config.php
    # Delete the temporary file
    rm temp-salt

欠点は、このスクリプトが行の内容ではなく行番号で操作することであり、それが完全ではない原因です。しかし、wp-content-sample.phpファイルが頻繁に変更される可能性は低いので、すべてが悪いわけではないと思います。

于 2013-01-02T20:57:20.027 に答える