2

シェフを使用して、ubuntu へのグラファイトのインストールを自動化しています。bash またはその他の手段を使用して、python manage.py syncdb を自動化する必要があります。

ubuntu@ip-xxx-xxx-xxx:/opt/graphite/webapp/graphite$ sudo python manage.py syncdb
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'root'): admin
E-mail address: test@gmail.com
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found.

以下を使用して、次のプロンプトを自動化する必要があります

Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'root'): admin
E-mail address: test@gmail.com
Password: test101
Password (again): test101

ありがとう

4

5 に答える 5

3

同じ問題があり、expect を使用して解決したので、私が書いた expect スクリプトを共有できると考えました。

set timeout -1
set program [ lindex $argv 0 ]
eval spawn $program [ lrange $argv 1 end ]
expect {
    "Would you like to create one now" {
            send "yes\r"
            expect "Username"
            send "admin\r"
            expect "E-mail"
            send "test@gmail.com\r"
            expect "Password"
            send "admin\r"
            expect "Password"
            send "admin\r"
            exp_continue
     } "Migrated" {
            expect eof
     }
}

デフォルトの管理者とパスワードを忘れずにカスタマイズしてください。

于 2013-07-16T15:25:50.677 に答える
2

あなたは期待することができます。sftp 以外で使用したことはありませんが、対話型のアプリケーションであれば動作するはずです。

于 2012-04-15T18:56:23.683 に答える
1

「入力」の問題を解決する必要があり、ファブリックを使用して管理者の作成を自動化したい場合は、--noinputフラグをsyncdbに渡し、作成済みのユーザー データを含むフィクスチャをロードすることを検討してください。

ここを見てください: django fabric syncdb

于 2012-10-11T16:15:01.500 に答える
0

データを標準入力としてプロセスにパイプするだけでよいでしょうか?

printf "%s\n" yes admin test@example.com test101 test101 | sudo python ...

また

sudo sh -c 'printf "%s\n" yes admin test@example.com test101 test101 | python ...'
于 2012-04-15T21:30:59.297 に答える