Skip to content

Instantly share code, notes, and snippets.

@agail
Last active March 28, 2023 07:20
Show Gist options
  • Save agail/e9c62fc99db33a7b1f52c1f76a7aa3e4 to your computer and use it in GitHub Desktop.
Save agail/e9c62fc99db33a7b1f52c1f76a7aa3e4 to your computer and use it in GitHub Desktop.
Quick start Script-server Docker

Intro

Quick way to get started with Script-Server docker

### directories ###
 ssdir=script-server
 mkdir -p /opt/${ssdir}/conf /opt/${ssdir}/runners /opt/${ssdir}/scripts /opt/${ssdir}/conf/theme
### conf.json ###
{
"access": {
        "allowed_users": [ "*" ],
        "admin_users": [ "*" ]
        },
"logging": {
    "execution_file": "$DATE-$ID.log",
    "execution_date_format": "%y-%m-%d_%H-%M"
  }
}
### Docker ###
#!/bin/bash

ssdir=script-server
 
f_conf () {
cat <<-EOF
{
"access": {
        "allowed_users": [ "*" ],
        "admin_users": [ "*" ]
        },
"logging": {
    "execution_file": "$DATE-$ID.log",
    "execution_date_format": "%y-%m-%d_%H-%M"
  }
}
EOF
}

f_directories () {
 for d in /opt/${ssdir}/conf /opt/${ssdir}/runners /opt/${ssdir}/scripts /opt/${ssdir}/conf/theme; do
    if [ ! -d "${d}" ]; then
        mkdir -p ${d}
    fi
 done
}

f_launch () {
 local _port=8000:5000
 local _name=jscript
 local _wdir=/opt/${ssdir}

 docker run -p ${_port} \
    -v ${_wdir}/conf/conf.json:/app/conf/conf.json \
    -v ${_wdir}/runners/:/app/conf/runners \
    -v ${_wdir}/scripts/:/app/scripts/ \
    -v ${_wdir}/conf/theme/:/app/conf/theme/ \
    --name ${_name} \
    bugy/script-server:dev
}

f_directories
if [ ! -f /opt/${ssdir}/conf/conf.json ]; then f_conf | tee /opt/${ssdir}/conf/conf.json; fi
f_launch
### themes ###

Info about theme customization

Simple theme switcher script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment