Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Northflank上部署找不到密码,使用shell输入alist admin得到的密码登陆提示密码错误 #12

Open
Weiming31 opened this issue Sep 18, 2023 · 4 comments

Comments

@Weiming31
Copy link

No description provided.

@wy580477
Copy link
Owner

wy580477 commented Sep 18, 2023

密码,在最早的日志里面。如果还是找不到,删除数据库重来。

shell 里面敲 alist admin 得不到密码的,你这么做没有连接数据库。

需要先执行下面的代码才行:

PARSE_DB_URL() {
    # extract the protocol
    proto="$(echo $DATABASE_URL | grep '://' | sed -e's,^\(.*://\).*,\1,g')"
    if [[ "${proto}" =~ postgres ]]; then
        export DB_TYPE=postgres
        export DB_SSL_MODE=require
    elif [[ "${proto}" =~ mysql ]]; then
        export DB_TYPE=mysql
        export DB_SSL_MODE=true
    fi

    # remove the protocol
    url=$(echo $DATABASE_URL | sed -e s,${proto},,g)

    # extract the user and password (if any)
    userpass="$(echo $url | grep @ | cut -d@ -f1)"
    export DB_PASS=$(echo $userpass | grep : | cut -d: -f2)
    if [ -n "$DB_PASS" ]; then
        export DB_USER=$(echo $userpass | grep : | cut -d: -f1)
    else
        export DB_USER=$userpass
    fi

    # extract the host -- updated
    hostport=$(echo $url | sed -e s,$userpass@,,g | cut -d/ -f1)
    export DB_PORT=$(echo $hostport | grep : | cut -d: -f2)
    if [ -n "$DB_PORT" ]; then
        export DB_HOST=`echo $hostport | grep : | cut -d: -f1`
    else
        export DB_HOST=$hostport
    fi
    if [[ ${DB_TYPE} = postgres ]] && [[ ${DB_PORT} = "" ]]; then
        export DB_PORT=5432
    fi

    # extract the name (if any)
    export DB_NAME="`echo $url | grep / | cut -d/ -f2- | sed 's|?.*||'`"
}

if [ "${DATABASE_URL}" != "" ]; then
    PARSE_DB_URL
fi

@Weiming31
Copy link
Author

谢谢大佬,我明白了🥰

@ningfeiyo
Copy link

密码,在最早的日志里面。如果还是找不到,删除数据库重来。

shell 里面敲 alist admin 得不到密码的,你这么做没有连接数据库。

需要先执行下面的代码才行:

PARSE_DB_URL() {
    # extract the protocol
    proto="$(echo $DATABASE_URL | grep '://' | sed -e's,^\(.*://\).*,\1,g')"
    if [[ "${proto}" =~ postgres ]]; then
        export DB_TYPE=postgres
        export DB_SSL_MODE=require
    elif [[ "${proto}" =~ mysql ]]; then
        export DB_TYPE=mysql
        export DB_SSL_MODE=true
    fi

    # remove the protocol
    url=$(echo $DATABASE_URL | sed -e s,${proto},,g)

    # extract the user and password (if any)
    userpass="$(echo $url | grep @ | cut -d@ -f1)"
    export DB_PASS=$(echo $userpass | grep : | cut -d: -f2)
    if [ -n "$DB_PASS" ]; then
        export DB_USER=$(echo $userpass | grep : | cut -d: -f1)
    else
        export DB_USER=$userpass
    fi

    # extract the host -- updated
    hostport=$(echo $url | sed -e s,$userpass@,,g | cut -d/ -f1)
    export DB_PORT=$(echo $hostport | grep : | cut -d: -f2)
    if [ -n "$DB_PORT" ]; then
        export DB_HOST=`echo $hostport | grep : | cut -d: -f1`
    else
        export DB_HOST=$hostport
    fi
    if [[ ${DB_TYPE} = postgres ]] && [[ ${DB_PORT} = "" ]]; then
        export DB_PORT=5432
    fi

    # extract the name (if any)
    export DB_NAME="`echo $url | grep / | cut -d/ -f2- | sed 's|?.*||'`"
}

if [ "${DATABASE_URL}" != "" ]; then
    PARSE_DB_URL
fi

我也是部署了,好像密码自动换了,能改一个密码定制的吗?用一段时间密码好像就变了

@xfxx20222
Copy link

谢谢大佬,我明白了🥰

没有看懂上面代码怎么使用,我应该填写哪个部分。。。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants