mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add EULA confirm message on server startup if EULA is not found.
This commit is contained in:
parent
0e942311fb
commit
dc83dc8fc8
@ -193,6 +193,35 @@ class Server:
|
|||||||
logger.info("Launching Server {} with command {}".format(self.name, self.server_command))
|
logger.info("Launching Server {} with command {}".format(self.name, self.server_command))
|
||||||
console.info("Launching Server {} with command {}".format(self.name, self.server_command))
|
console.info("Launching Server {} with command {}".format(self.name, self.server_command))
|
||||||
|
|
||||||
|
e_flag = False
|
||||||
|
|
||||||
|
if helper.check_file_exists(os.path.join(self.settings['path'], 'eula.txt')):
|
||||||
|
f = open(os.path.join(self.settings['path'], 'eula.txt'), 'r')
|
||||||
|
line = f.readline().lower()
|
||||||
|
if line == 'eula=true':
|
||||||
|
e_flag = True
|
||||||
|
|
||||||
|
elif line == 'eula = true':
|
||||||
|
e_flag = True
|
||||||
|
|
||||||
|
elif line == 'eula= true':
|
||||||
|
e_flag = True
|
||||||
|
|
||||||
|
elif line == 'eula =true':
|
||||||
|
e_flag = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
e_flag = False
|
||||||
|
else:
|
||||||
|
e_flag = False
|
||||||
|
|
||||||
|
if e_flag == False:
|
||||||
|
websocket_helper.broadcast('send_eula_bootbox', {
|
||||||
|
'id': self.server_id
|
||||||
|
})
|
||||||
|
return False
|
||||||
|
f.close()
|
||||||
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
logger.info("Windows Detected")
|
logger.info("Windows Detected")
|
||||||
creationflags=subprocess.CREATE_NEW_CONSOLE
|
creationflags=subprocess.CREATE_NEW_CONSOLE
|
||||||
@ -346,7 +375,7 @@ class Server:
|
|||||||
if self.settings['crash_detection']:
|
if self.settings['crash_detection']:
|
||||||
logger.warning("The server {} has crashed and will be restarted. Restarting server".format(name))
|
logger.warning("The server {} has crashed and will be restarted. Restarting server".format(name))
|
||||||
console.warning("The server {} has crashed and will be restarted. Restarting server".format(name))
|
console.warning("The server {} has crashed and will be restarted. Restarting server".format(name))
|
||||||
self.run_threaded_server()
|
self.run_threaded_server('en_EN')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.critical(
|
logger.critical(
|
||||||
@ -420,6 +449,13 @@ class Server:
|
|||||||
console.info("Removing old crash detection watcher thread")
|
console.info("Removing old crash detection watcher thread")
|
||||||
schedule.clear(self.name)
|
schedule.clear(self.name)
|
||||||
|
|
||||||
|
def agree_eula(self, user_lang):
|
||||||
|
file = os.path.join(self.server_path, 'eula.txt')
|
||||||
|
f = open(file, 'w')
|
||||||
|
f.write('eula=true')
|
||||||
|
f.close
|
||||||
|
self.run_threaded_server(user_lang)
|
||||||
|
|
||||||
def is_backup_running(self):
|
def is_backup_running(self):
|
||||||
if self.is_backingup:
|
if self.is_backingup:
|
||||||
return True
|
return True
|
||||||
|
@ -207,6 +207,10 @@ class AjaxHandler(BaseHandler):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Could not find PID for requested termsig. Full error: {}".format(e))
|
logger.error("Could not find PID for requested termsig. Full error: {}".format(e))
|
||||||
return
|
return
|
||||||
|
elif page == "eula":
|
||||||
|
server_id = self.get_argument('id', None)
|
||||||
|
svr = self.controller.get_server_obj(server_id)
|
||||||
|
svr.agree_eula(self.controller.users.get_user_lang_by_id(user_data['user_id']))
|
||||||
|
|
||||||
@tornado.web.authenticated
|
@tornado.web.authenticated
|
||||||
def delete(self, page):
|
def delete(self, page):
|
||||||
|
@ -237,6 +237,57 @@ if (webSocket) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (webSocket) {
|
||||||
|
webSocket.on('send_eula_bootbox', function (server_id) {
|
||||||
|
var x = document.querySelector('.bootbox');
|
||||||
|
if(x){
|
||||||
|
x.remove()}
|
||||||
|
var x = document.querySelector('.modal-backdrop');
|
||||||
|
if(x){
|
||||||
|
x.remove()}
|
||||||
|
bootbox.confirm({
|
||||||
|
title: '{% raw translate("error", "eulaTitle", data['lang']) %}',
|
||||||
|
message: '{% raw translate("error", "eulaMsg", data['lang']) %} <br><br><a href="https://account.mojang.com/documents/minecraft_eula" target="_blank">EULA</a><br><br>{% raw translate("error", "eulaAgree", data['lang']) %}',
|
||||||
|
buttons: {
|
||||||
|
confirm: {
|
||||||
|
label: 'Yes',
|
||||||
|
className: 'btn-info'
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
label: 'No',
|
||||||
|
className: 'btn-secondary'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: function (result) {
|
||||||
|
if(result == true){
|
||||||
|
eulaAgree(server_id.id)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function eulaAgree (server_id, command){
|
||||||
|
<!-- this getCookie function is in base.html-->
|
||||||
|
var token = getCookie("_xsrf");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
headers: {'X-XSRFToken': token},
|
||||||
|
url: '/ajax/eula?id='+ server_id,
|
||||||
|
success: function(data){
|
||||||
|
console.log("got response:");
|
||||||
|
console.log(data);
|
||||||
|
location.reload();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function warn(message) {
|
function warn(message) {
|
||||||
var closeEl = document.createElement('span');
|
var closeEl = document.createElement('span');
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }}<br />
|
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }}<br />
|
||||||
|
|
||||||
{% if server['stats']['desc'] != 'False' %}
|
{% if server['stats']['desc'] != 'False' %}
|
||||||
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ server['stats']['desc'] }}</span> <br />
|
{{ server['stats']['desc'] }} <br />
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
{% if server['stats']['version'] != 'False' %}
|
{% if server['stats']['version'] != 'False' %}
|
||||||
@ -221,7 +221,6 @@
|
|||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="/static/assets/js/motd.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="popover"]').popover();
|
$('[data-toggle="popover"]').popover();
|
||||||
@ -229,10 +228,6 @@ $(document).ready(function(){
|
|||||||
$('.too_small').popover("show");
|
$('.too_small').popover("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
var all_motds = Array.from(document.getElementsByClassName('input_motd'));
|
|
||||||
for (element of all_motds) {
|
|
||||||
initParser(element.id, element.id);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
$(window).ready(function(){
|
$(window).ready(function(){
|
||||||
$('body').click(function(){
|
$('body').click(function(){
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
"error": "Error!",
|
"error": "Error!",
|
||||||
"start-error": "Server {} failed to start with error code: {}",
|
"start-error": "Server {} failed to start with error code: {}",
|
||||||
"closedPort": "We have detected port {} may not be open on the host network or a firewall is blocking it. Remote client connections to the server may be limited.",
|
"closedPort": "We have detected port {} may not be open on the host network or a firewall is blocking it. Remote client connections to the server may be limited.",
|
||||||
"internet": "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited."
|
"internet": "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited.",
|
||||||
|
"eulaTitle": "Agree To EULA",
|
||||||
|
"eulaMsg": "You must agree to the EULA. A copy of the Mojang EULA is linked under this message.",
|
||||||
|
"eulaAgree": "Do you agree?"
|
||||||
},
|
},
|
||||||
"404": {
|
"404": {
|
||||||
"contact": "Contact Crafty Control Support via Discord",
|
"contact": "Contact Crafty Control Support via Discord",
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
"error": "Virhe!",
|
"error": "Virhe!",
|
||||||
"start-error": "Palvelin {} ei käynnistynyt virhekoodilla: {}",
|
"start-error": "Palvelin {} ei käynnistynyt virhekoodilla: {}",
|
||||||
"closedPort": "Olemme havainneet, että portti {} ei ehkä ole auki isäntäverkossa tai palomuuri estää sen. Etäasiakkaan yhteydet palvelimeen voivat olla rajallisia.",
|
"closedPort": "Olemme havainneet, että portti {} ei ehkä ole auki isäntäverkossa tai palomuuri estää sen. Etäasiakkaan yhteydet palvelimeen voivat olla rajallisia.",
|
||||||
"internet": "Olemme havainneet, että Crafty -koneella ei ole Internet -yhteyttä. Asiakasyhteydet palvelimelle voivat olla rajalliset."
|
"internet": "Olemme havainneet, että Crafty -koneella ei ole Internet -yhteyttä. Asiakasyhteydet palvelimelle voivat olla rajalliset.",
|
||||||
|
"eulaTitle": "Hyväksy EULA",
|
||||||
|
"eulaMsg": "Sinun on hyväksyttävä EULA. Kopio Mojang EULA:sta on linkitetty tämän viestin alla.",
|
||||||
|
"eulaAgree": "Oletko samaa mieltä?"
|
||||||
},
|
},
|
||||||
"404": {
|
"404": {
|
||||||
"contact": "Ota yhteyttä Crafty Control -tukeen Discordin kautta",
|
"contact": "Ota yhteyttä Crafty Control -tukeen Discordin kautta",
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
"error": "Erreur !",
|
"error": "Erreur !",
|
||||||
"start-error": "Le serveur {} n'a pas pu démarrer avec le code d'erreur : {}",
|
"start-error": "Le serveur {} n'a pas pu démarrer avec le code d'erreur : {}",
|
||||||
"closedPort": "Nous avons détecté que le port {} n'est peut-être pas ouvert sur le réseau hôte ou qu'un pare-feu le bloque. Les connexions des clients distants au serveur peuvent être limitées.",
|
"closedPort": "Nous avons détecté que le port {} n'est peut-être pas ouvert sur le réseau hôte ou qu'un pare-feu le bloque. Les connexions des clients distants au serveur peuvent être limitées.",
|
||||||
"internet": "Nous avons détecté que la machine exécutant Crafty n'a pas de connexion à Internet. Les connexions client au serveur peuvent être limitées."
|
"internet": "Nous avons détecté que la machine exécutant Crafty n'a pas de connexion à Internet. Les connexions client au serveur peuvent être limitées.",
|
||||||
|
"eulaTitle": "Accepter le EULA",
|
||||||
|
"eulaMsg": "Vous devez accepter le EULA. Une copie du CLUF de Mojang est liée sous ce message.",
|
||||||
|
"eulaAgree": "Êtes-vous d'accord?"
|
||||||
},
|
},
|
||||||
"404": {
|
"404": {
|
||||||
"contact": "Contacter le Support de Crafty Control via Discord",
|
"contact": "Contacter le Support de Crafty Control via Discord",
|
||||||
|
Loading…
Reference in New Issue
Block a user