Skip to content

Commit

Permalink
add custom repassword
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 14, 2021
1 parent 32c2d60 commit 56e142a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion docker/mysql/repassword.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 56e142a

Please sign in to comment.