add custom repassword

This commit is contained in:
kuaifan 2021-12-14 19:51:41 +08:00
parent 32c2d60f7e
commit 56e142ac05
2 changed files with 6 additions and 2 deletions

2
cmd
View File

@ -251,7 +251,7 @@ if [ $# -gt 0 ]; then
echo -e "${OK} ${GreenBG} 卸载完成 ${Font}"
elif [[ "$1" == "repassword" ]]; then
shift 1
run_exec mariadb "sh /etc/mysql/repassword.sh"
run_exec mariadb "sh /etc/mysql/repassword.sh \"$@\""
elif [[ "$1" == "dev" ]] || [[ "$1" == "development" ]]; then
shift 1
run_compile dev

View File

@ -1,10 +1,14 @@
#!/bin/sh
new_password=$1
GreenBG="\033[42;37m"
Font="\033[0m"
new_encrypt=$(date +%s%N | md5sum | awk '{print $1}' | cut -c 1-6)
new_password=$(date +%s%N | md5sum | awk '{print $1}' | cut -c 1-16)
if [ -z "$new_password" ]; then
new_password=$(date +%s%N | md5sum | awk '{print $1}' | cut -c 1-16)
fi
md5_password=$(echo -n `echo -n $new_password | md5sum | awk '{print $1}'`$new_encrypt | md5sum | awk '{print $1}')
content=$(echo "select \`email\` from ${MYSQL_PREFIX}users where \`userid\`=1;" | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE)