diff --git a/README.md b/README.md
index 4af0155..837b454 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,11 @@ Bot the can play :
## Menu
1. [Web Interface](#web-interface)
2. [Installation](#installation)
-3. [Generate a certificate](#optional-generate-a-certificate)
-4. [Starting the bot](#starting-the-bot)
-5. [Custom commands](#custom-commands)
-6. [Contributors](#contributors)
+3. [Update](#udpate)
+4. [Generate a certificate](#optional-generate-a-certificate)
+5. [Starting the bot](#starting-the-bot)
+6. [Custom commands](#custom-commands)
+7. [Contributors](#contributors)
### Web interface
@@ -29,7 +30,17 @@ You can enable the web interface into the configuration.ini file.
1. You need python 3 with opuslib and protobuf (look at the requirement of pymumble)
2. The Bot uses ffmpeg, so you know what you have to do if ffmpeg isn't in your package manager. I personally use [this repository](http://repozytorium.mati75.eu/) on my raspberry.
-Example installation commands for Debian and Ubuntu:
+To Install botamusique (stable and build-in auto-update):
+```
+curl -Lo botamusique.tar.gz https://azlux.fr/botamusique/sources.tar.gz
+tar -xzf botamusique.tar.gz
+cd botamusique
+python3 -m venv venv
+venv/bin/pip install wheel
+venv/bin/pip install -r requirements.txt
+```
+
+For the master version, you can use Git installation commands (no build-in auto-update allowed):
```
apt install python3-venv ffmpeg libjpeg-dev zlibc zlib1g zlib1g-dev
git clone --recurse-submodules https://github.com/azlux/botamusique.git
@@ -39,6 +50,17 @@ venv/bin/pip install wheel
venv/bin/pip install -r requirements.txt
```
+### Update
+If using the recommanded install, you can send to the bot `!update`(command by default)
+
+If using git, you need to make the update manually:
+```
+git pull --all
+git submodule update
+venv/bin/pip install --upgrade -r requirements.txt
+```
+
+
### (Optional) Generate a certificate
`$ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout botamusique.pem -out botamusique.pem -subj "/CN=botamusique"`
diff --git a/media/radio.py b/media/radio.py
index a864d8a..04d9345 100644
--- a/media/radio.py
+++ b/media/radio.py
@@ -5,7 +5,6 @@ import json
import http.client
import struct
-
def get_radio_server_description(url):
p = re.compile('(https?\:\/\/[^\/]*)', re.IGNORECASE)
res = re.search(p, url)
diff --git a/mumbleBot.py b/mumbleBot.py
index 4784125..1aece0b 100644
--- a/mumbleBot.py
+++ b/mumbleBot.py
@@ -55,6 +55,8 @@ type : file
user
"""
+version = 2
+
class MumbleBot:
def __init__(self, args):
@@ -331,17 +333,7 @@ class MumbleBot:
if self.is_admin(user):
self.mumble.users[text.actor].send_text_message("Starting the update")
# Need to be improved
- tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
- msg = ""
- if "Requirement already up-to-date" in tp:
- msg += "Youtube-dl is up-to-date"
- else:
- msg += "Update done : " + tp.split('Successfully installed')[1]
- if 'up-to-date' not in sp.check_output(['/usr/bin/env', 'git', 'pull']).decode():
- # Need to change it with release tag
- msg += "
I'm up-to-date"
- else:
- msg += "
I have available updates, need to do it manually"
+ msg = util.update(version)
self.mumble.users[text.actor].send_text_message(msg)
else:
self.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
@@ -697,6 +689,13 @@ if __name__ == '__main__':
db = configparser.ConfigParser(interpolation=None, allow_no_value=True, delimiters='²')
db.read(var.dbfile, encoding='latin-1')
+ if 'url_ban' not in db.sections():
+ db.add_section('url_ban')
+ if 'bot' not in db.sections():
+ db.add_section('bot')
+ if 'user_ban' not in db.sections():
+ db.add_section('user_ban')
+
if len(parsed_configs) == 0:
logging.error('Could not read configuration from file \"{}\"'.format(args.config), file=sys.stderr)
sys.exit()
diff --git a/update.sh b/update.sh
new file mode 100644
index 0000000..1afb4eb
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,5 @@
+curl -Lo /tmp/botamusique.tar.gz https://azlux.fr/botamusique/sources.tar.gz
+tar -xzf /tmp/botamusique.tar.gz -C /tmp/botamusique
+cp -r /tmp/botamusique/* .
+rm -r /tmp/botamusique
+rm -r /tmp/botamusique.tar.gz
\ No newline at end of file
diff --git a/util.py b/util.py
index 38ca330..9057db5 100644
--- a/util.py
+++ b/util.py
@@ -5,6 +5,9 @@ import magic
import os
import variables as var
import zipfile
+import urllib.request
+import subprocess as sp
+import logging
def get_recursive_filelist_sorted(path):
@@ -78,6 +81,24 @@ def get_user_ban():
return res
+def update(version):
+ v = int(urllib.request.urlopen(urllib.request.Request("https://azlux.fr/botamusique/version")).read())
+ if v > version:
+ logging.info('New version, starting update')
+ tp = sp.check_output(['/usr/bin/env', 'bash', 'update.sh']).decode()
+ logging.debug(tp)
+ msg = "New version installed"
+ else:
+ logging.info('Starting update youtube-dl via pip3')
+ tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
+ msg = ""
+ if "Requirement already up-to-date" in tp:
+ msg += "Youtube-dl is up-to-date"
+ else:
+ msg += "Update done : " + tp.split('Successfully installed')[1]
+ return msg
+
+
def user_ban(user):
var.db.set("user_ban", user, None)
res = "User " + user + " banned"