47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import configparser
|
|
import os
|
|
import urllib.parse
|
|
|
|
CONFIG_FILE = '/etc/spoc/spoc.conf'
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read(CONFIG_FILE)
|
|
|
|
NETWORK_INTERFACE = config.get('general', 'network-interface', fallback='spocbr0')
|
|
|
|
DATA_DIR = config.get('general', 'data-dir', fallback='/var/lib/spoc/')
|
|
APPS_DIR = os.path.join(DATA_DIR, 'apps/')
|
|
CONTAINERS_DIR = os.path.join(DATA_DIR, 'containers/')
|
|
LAYERS_DIR = os.path.join(DATA_DIR, 'layers/')
|
|
VOLUMES_DIR = os.path.join(DATA_DIR, 'volumes/')
|
|
HOSTS_FILE = os.path.join(DATA_DIR, 'hosts')
|
|
REPO_FILE = os.path.join(DATA_DIR, 'repository.json')
|
|
|
|
LOCK_DIR = '/run/lock'
|
|
LOCK_FILE = os.path.join(LOCK_DIR, 'spoc.lock')
|
|
HOSTS_LOCK_FILE = os.path.join(LOCK_DIR, 'spoc-hosts.lock')
|
|
REPO_LOCK_FILE = os.path.join(LOCK_DIR, 'spoc-local.lock')
|
|
|
|
TMP_DIR = os.path.join(DATA_DIR, 'tmp/')
|
|
TMP_APPS_DIR = os.path.join(TMP_DIR, 'apps/')
|
|
TMP_LAYERS_DIR = os.path.join(TMP_DIR, 'layers/')
|
|
LOG_DIR = config.get('general', 'log-dir', fallback='/var/log/spoc')
|
|
|
|
PUB_DIR = config.get('publish', 'publish-dir', fallback=os.path.join(DATA_DIR, 'publish'))
|
|
PUB_LAYERS_DIR = os.path.join(PUB_DIR, 'layers/')
|
|
PUB_APPS_DIR = os.path.join(PUB_DIR, 'apps/')
|
|
PUB_REPO_FILE = os.path.join(PUB_DIR, 'repository.json')
|
|
PUB_SIG_FILE = os.path.join(PUB_DIR, 'repository.sig')
|
|
PUB_PRIVKEY_FILE = config.get('publish', 'signing-key', fallback='/etc/spoc/publish.key')
|
|
PUB_LOCK_FILE = os.path.join(LOCK_DIR, 'spoc-publish.lock')
|
|
|
|
# URLs which are an actual directories need to end with trailing slash
|
|
ONLINE_BASE_URL = '{}/'.format(config.get('repo', 'url', fallback='https://localhost').rstrip('/'))
|
|
ONLINE_LAYERS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'layers/')
|
|
ONLINE_APPS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'apps/')
|
|
ONLINE_REPO_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.json')
|
|
ONLINE_SIG_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.sig')
|
|
ONLINE_PUBKEY = config.get('repo', 'public-key', fallback='')
|