#!/bin/sh SCRIPT="$(basename $0)" usage() { cat <] Parameters: -d Enables the default user so that no password is required for the GUI. the new admin password for the GUI. (Required if -d is not specified, ignored when -d is specified.) EOH exit } USR="admin" KEY="" DFLT_USR="" for o in $*; do case "$o" in -d) DFLT_USR="$USR";; -*) usage;; *) KEY="$o" esac done if [ -z "$DFLT_USR" -a -z "$KEY" ]; then echo "ERROR: No password specified" echo usage elif [ "$DFLT_USR" = "admin" ]; then uci set web.default.default_user='usr_admin' uci set web.uidefault.defaultuser='admin' echo [$SCRIPT]: The default user has been enabled for the web GUI - no password required to login else SRP=$(newsrpuser -f -u $USR -p $KEY) SALT=$(echo $SRP | cut -d' ' -f1) VERIFIER=$(echo $SRP | cut -d' ' -f2) uci set web.usr_admin.srp_salt=$SALT uci set web.usr_admin.srp_verifier=$VERIFIER uci -q delete web.default.default_user uci -q delete web.uidefault.defaultuser echo [$SCRIPT]: The web GUI password for the admin user has been set to: $KEY fi uci commit web /etc/init.d/nginx restart