• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright (C) 2019 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import json
17import os
18import sys
19
20with open("/etc/discord-irc.json") as f:
21  cfg = json.load(f)
22
23cfg[0]["nickname"] = os.getenv("NICKNAME")
24cfg[0]["discordToken"] = os.getenv("DISCORD_TOKEN")
25
26if cfg[0]["nickname"] is None:
27  sys.stderr.write("NICKNAME env var not set\n")
28  sys.exit(1)
29
30if cfg[0]["discordToken"] is None:
31  sys.stderr.write("DISCORD_TOKEN env var not set\n")
32  sys.exit(1)
33
34with open("/tmp/discord-irc-merged.json", "w") as f:
35  json.dump(cfg, f)
36
37os.execl("/usr/bin/supervisord", "supervisord")
38