redash二次开发记录--去掉仪表板的跳转链接

redash官网

https://redash.io/

redash文档

https://redash.io/help/

redash issues

https://github.com/getredash/redash/issues

redash安装

如果是通过docker安装的话,获取到redash源码之后找到其setup文件夹下的setup.sh文件,直接执行sh setup.sh 就可以执行1、安装docker;2、安装docker-compose;3、获取redash镜像;4、运行docker-compose.yml文件
非docker安装请参考https://www.cnblogs.com/shhnwangjian/p/8417748.html
setup文件如果是ubuntu16.04系统的话需要修改,也可进行个性化配置。以下是参考:

#!/usr/bin/env bash
# This script setups dockerized Redash on Ubuntu 18.04.
set -eu

REDASH_BASE_PATH=/opt/redash

install_docker(){
    # Install Docker
    sudo apt-get update
    sudo apt-get -yy install apt-transport-https ca-certificates curl software-properties-common wget pwgen
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    sudo apt-get update && sudo apt-get -y install docker-ce

    # Install Docker Compose
    sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose

    # Allow current user to run Docker commands
    sudo usermod -aG docker $USER
} 

create_directories() {
    if [ ! -e $REDASH_BASE_PATH ]; then
        sudo mkdir -p $REDASH_BASE_PATH
        sudo chown $USER:$USER $REDASH_BASE_PATH
    fi

    if [ ! -e $REDASH_BASE_PATH/postgres-data ]; then
        mkdir $REDASH_BASE_PATH/postgres-data
    fi
    if [ ! -e $REDASH_BASE_PATH/redis-data ]; then
        mkdir $REDASH_BASE_PATH/redis-data
    fi
}

create_config() {
    if [ -e $REDASH_BASE_PATH/env ]; then
        rm $REDASH_BASE_PATH/env
        touch $REDASH_BASE_PATH/env
    fi
    COOKIE_SECRET=$(pwgen -1s 32)
    SECRET_KEY=$(pwgen -1s 32)
    POSTGRES_PASSWORD="Biyjatqdw..."
    REDASH_DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@postgres/postgres"

    echo "PYTHONUNBUFFERED=0" >> $REDASH_BASE_PATH/env
    echo "REDASH_LOG_LEVEL=INFO" >> $REDASH_BASE_PATH/env
    echo "REDASH_REDIS_URL=redis://redis:6379/0" >> $REDASH_BASE_PATH/env
    echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $REDASH_BASE_PATH/env
    echo "REDASH_COOKIE_SECRET=$COOKIE_SECRET" >> $REDASH_BASE_PATH/env
    echo "REDASH_SECRET_KEY=$SECRET_KEY" >> $REDASH_BASE_PATH/env
    echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env
    echo "REDASH_MAIL_SERVER=smtp.163.com" >> $REDASH_BASE_PATH/env # default: localhost
    echo "REDASH_MAIL_PORT=465" >> $REDASH_BASE_PATH/env # default: 25
    echo "REDASH_MAIL_USE_TLS=false" >> $REDASH_BASE_PATH/env # default: false
    echo "REDASH_MAIL_USE_SSL="true"" >> $REDASH_BASE_PATH/env # default: false
    echo "REDASH_MAIL_USERNAME=xxx" >> $REDASH_BASE_PATH/env # default: None
    echo "REDASH_MAIL_PASSWORD=xxx" >> $REDASH_BASE_PATH/env # default: None
    echo "REDASH_MAIL_DEFAULT_SENDER=xxx" >> $REDASH_BASE_PATH/env
    echo "REDASH_HOST=xxxxxxx" >> $REDASH_BASE_PATH/env

}

setup_compose() {
    REQUESTED_CHANNEL=stable
    LATEST_VERSION=`curl -s "https://version.redash.io/api/releases?channel=$REQUESTED_CHANNEL"  | json_pp  | grep "docker_image" | head -n 1 | awk 'BEGIN{FS=":"}{print $3}' | awk 'BEGIN{FS="\""}{print $1}'`
    cp ./docker-compose.yml $REDASH_BASE_PATH
    cd $REDASH_BASE_PATH
    REDASH_BRANCH="${REDASH_BRANCH:-master}" # Default branch/version to master if not specified in REDASH_BRANCH env var
    #wget https://raw.githubusercontent.com/getredash/redash/${REDASH_BRANCH}/setup/docker-compose.yml
    sed -ri "s/image: redash\/redash:([A-Za-z0-9.-]*)/image: redash\/redash:$LATEST_VERSION/" docker-compose.yml
    echo "export COMPOSE_PROJECT_NAME=redash" >> ~/.profile
    echo "export COMPOSE_FILE=/opt/redash/docker-compose.yml" >> ~/.profile
    export COMPOSE_PROJECT_NAME=redash
    export COMPOSE_FILE=/opt/redash/docker-compose.yml
    sudo docker-compose run --rm server create_db
    sudo docker-compose up -d
}

install_docker
create_directories
create_config
setup_compose

请务必注释掉wget一行,否则你对本文件夹docker-compose.yml的将无法达到效果。

去掉链接:

阅读源码,找到关键代码位置,修改,测试,打包docker镜像。
已制好的镜像获取方法: docker pull spritinme/redash:noLink
由于没有在本地搭建redash环境,更改过程还是比较艰难的,正好让自己熟悉了docker的一些操作

docker cp

docker cp 可以实现宿主机和容器之间的文件互通,语法如下
docker cp 想要复制的文件 想要复制到的目录

docker exec -it contaierID /bin/bash

可以使用容器内部的命令行,ctrl + p + q 退出容器
docker exec -it contaierID /bin/sh xxx.sh 可以直接执行容器内的shell脚本

redash的页面基本是用node.js写的,使用flask的模板的只有其与账号有关的页面。

你可能感兴趣的:(python)