Skip to content

Commit

Permalink
Merge pull request #26 from atlas-bi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sur.la.route authored Nov 26, 2021
2 parents 444e5ac + 80cc6da commit 0b98e75
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cancel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ name: cancel

on:
push:
branches:
- '!master'

jobs:
cancel:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: codeQL

on:
push:
branches:
- '!master'
pull_request:
schedule:
- cron: 16 7 * * 4
Expand Down
4 changes: 4 additions & 0 deletions packages/atlas-hub-<version>/atlas-hub
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ INSTALL_DIR="$BASE_DIR/app"
USER_DIR="/etc/atlas-hub"
BACKUP_DIR="$USER_DIR/backup"
LOG_DIR="/var/log/atlas-hub"
EXTERNAL_URL=${EXTERNAL_URL:-$HOSTNAME}

HIST_DATE=$(date +"%s_%Y_%m_%d")

Expand Down Expand Up @@ -85,6 +86,9 @@ configure(){
python3 -c "from installers import build_secrets; build_secrets()"

fmt_yellow "Updating configuration"

install_configuration

python3 -c "from installers import build_web_configuration; build_web_configuration(\"$INSTALL_DIR\", \"/etc/atlas-hub/config.ini\")"

fmt_yellow "Configuring Nginx"
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas-hub-<version>/config.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MASTER]
; web address used to access the site
HOST='localhost'
EXTERNAL_URL='localhost'

; min requirements to keep tasks running
; MIN_DISK_SPACE=1 * 1024 * 1024 * 1024
Expand Down
14 changes: 2 additions & 12 deletions packages/atlas-hub-<version>/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
python3 -m pip install colorama tqdm requests -q --no-warn-script-location

VERSION=<version>
EXTERNAL_URL=${EXTERNAL_URL:-$HOSTNAME}

BASE_DIR="/usr/lib/atlas-hub"
INSTALL_DIR="$BASE_DIR/app"
Expand All @@ -18,18 +19,7 @@ cd "$BASE_DIR"
# create pass file
python3 -c "from installers import build_secrets; build_secrets()"



# install default configuration if missing
if [ ! -e "$USER_DIR/config.ini" ]
then
if [ ! -d "$USER_DIR" ]; then
mkdir -p "$USER_DIR"
fi
mv $BASE_DIR/config.ini /etc/atlas-hub/config.ini
else
rm $BASE_DIR/config.ini
fi
install_configuration

# download app
python3 -c "from installers import download; download(\"https://github.com/atlas-bi/atlas-automation-hub/archive/refs/tags/$VERSION.tar.gz\", \"Atlas Hub $VERSION\", \"app.tar.gz\")"
Expand Down
13 changes: 13 additions & 0 deletions packages/atlas-hub-<version>/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ name() {

}

install_configuration(){
# install default configuration if missing
if [ ! -e "$USER_DIR/config.ini" ]
then
if [ ! -d "$USER_DIR" ]; then
mkdir -p "$USER_DIR"
fi
# apply initial external url
sed -i -e "s/EXTERNAL_URL='localhost'/EXTERNAL_URL='${EXTERNAL_URL}'/g" "$BASE_DIR/config.ini" > /dev/null
cp "$BASE_DIR/config.ini" /etc/atlas-hub/config.ini
fi
}

stop_services(){
BASE_DIR="/usr/lib/atlas-hub"
INSTALL_DIR="$BASE_DIR/app"
Expand Down
12 changes: 8 additions & 4 deletions packages/atlas-hub-<version>/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def build_web_configuration(install_dir: str, config_ini: str) -> None:
configuration = configparser.ConfigParser()
configuration.read(config_ini)

if configuration.has_section("MASTER") and "HOST" in configuration["MASTER"]:
hostname = configuration["MASTER"]["HOST"]
if (
configuration.has_section("MASTER")
and "EXTERNAL_URL" in configuration["MASTER"]
):
hostname = configuration["MASTER"]["EXTERNAL_URL"]
else:
hostname = socket.gethostname()

Expand Down Expand Up @@ -274,8 +277,9 @@ def build_nginx_configuration(config_ini: str) -> None:
atlas_config.read(config_ini)

hostname = (
atlas_config["MASTER"]["HOST"]
if atlas_config.has_section("MASTER") and "HOST" in atlas_config["MASTER"]
atlas_config["MASTER"]["EXTERNAL_URL"]
if atlas_config.has_section("MASTER")
and "EXTERNAL_URL" in atlas_config["MASTER"]
else socket.gethostname()
)

Expand Down
7 changes: 5 additions & 2 deletions packages/atlas-hub-<version>/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ cp -r "atlas-hub-<version>" "atlas-hub-$VERSION" \
&& find . -type f -name "*" -exec sed -i'' -e "s/<version>/$VERSION/g" {} + \
&& debuild --no-tgz-check -us -uc \
&& cd .. \
&& EXPORT EXTERNAL_URL="$HOSTNAME"; apt-get install ./atlas-hub_*.deb -y
&& apt-get install ./atlas-hub_*.deb -y


```

## To install a build
Expand All @@ -41,6 +40,10 @@ curl -s --compressed "https://atlas-bi.github.io/ppa/deb/KEY.gpg" | sudo apt-key
sudo curl -s --compressed -o /etc/apt/sources.list.d/atlas.list "https://atlas-bi.github.io/ppa/deb/atlas.list"
sudo apt update
sudo apt install atlas-hub

# or to specify the external url directory
EXPORT EXTERNAL_URL='https://google.com'; sudo apt install atlas-hub

```

## Where the files should end up
Expand Down

0 comments on commit 0b98e75

Please sign in to comment.