-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.py
73 lines (70 loc) · 2.58 KB
/
backup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import subprocess
import discord
print("MONAGE BACKUP MODULE STARTED")
import configparser
config = configparser.ConfigParser()
config.read('/root/dismona.conf')
section1 = 'development'
discord_token = config.get(section1, 'discord_token')
db_user = config.get(section1, 'db_user')
db_password = config.get(section1, 'db_password')
db_host = config.get(section1, 'db_host')
db_name = config.get(section1, 'db_name')
client = discord.Client()
@client.event
async def on_message(message):
if message.content.startswith("/startfaucet"):
cmd = "pgrep -a python | grep '/root/dismona/faucet.py'"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
my_pid, err = process.communicate()
if len(my_pid.splitlines()) >0:
s = 'Faucet Module is already running!'
await client.send_message(message.channel, s)
exit()
else:
s = 'Starting Faucet Module..'
await client.send_message(message.channel, s)
cmd = "startfaucet"
subprocess.Popen(cmd)
s = "Started!"
await client.send_message(message.channel, s)
if message.content.startswith("/status"):
cmd = "pgrep -a python | grep '/root/dismona/main.py'"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
my_pid, err = process.communicate()
if len(my_pid.splitlines()) >0:
s = 'Main Module: Running'
else:
s = 'Main Module: Down\nRestarting process is starting..'
await client.send_message(message.channel, s)
cmd = "refresh"
subprocess.Popen(cmd)
cmd = "pgrep -a python | grep '/root/dismona/faucet.py'"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
my_pid, err = process.communicate()
if len(my_pid.splitlines()) >0:
s = 'Faucet Module: Running'
await client.send_message(message.channel, s)
else:
s = 'Faucet Module: Down\nTo start this, please use /startfaucet. '
await client.send_message(message.channel, s)
if message.content.startswith("/start"):
cmd = "pgrep -a python | grep '/root/dismona/main.py'"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
my_pid, err = process.communicate()
if len(my_pid.splitlines()) >0:
a = "null"
else:
s = 'Main Module: Down\nRestarting process is starting..'
await client.send_message(message.channel, s)
cmd = "refresh"
subprocess.Popen(cmd)
cmd = "pgrep -a python | grep '/root/dismona/faucet.py'"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
my_pid, err = process.communicate()
client.run(discord_token)