--- a/scripts/check_init_admin.py +++ b/scripts/check_init_admin.py @@ -310,7 +310,7 @@ def create_admin(email, passwd): def ask_admin_email(): print() print('----------------------------------------') - print('It\'s the first time you start the seafile server. Now let\'s create the admin account') + print('Let\'s create the admin account') print('----------------------------------------') def validate(email): # whitespace is not allowed @@ -350,8 +350,15 @@ def ask_admin_password(): rpc = RPC() -def main(): +def main(argv): + if len(argv) > 1 and argv[1] == 'has-admin': + sys.exit(1 if need_create_admin() else 0) + if not need_create_admin(): + print('') + print('A seafile admin account already exists.') + print('Log into seahub to add additional accounts.') + print('If you cannot log in, run reset-seafile-admin to add a new admin account.') return password_file = os.path.join(os.environ['SEAFILE_CENTRAL_CONF_DIR'], 'admin.txt') @@ -369,7 +376,7 @@ def main(): if __name__ == '__main__': try: - main() + main(sys.argv) except KeyboardInterrupt: print('\n\n\n') print(Utils.highlight('Aborted.')) @@ -379,3 +386,4 @@ if __name__ == '__main__': print() print(Utils.highlight('Error happened during creating seafile admin.')) print() + sys.exit(1) --- a/scripts/seahub.sh +++ b/scripts/seahub.sh @@ -250,7 +250,10 @@ function stop_seahub () { function check_init_admin() { check_init_admin_script=${INSTALLPATH}/check_init_admin.py - if ! $PYTHON $check_init_admin_script; then + if ! $PYTHON $check_init_admin_script has-admin; then + echo "Error: there is no seafile admin account." + echo "Have you run create-seafile-admin before this?" + echo "" exit 1 fi }