ajout de la route d'extinction du système
This commit is contained in:
@@ -158,7 +158,7 @@ def current_user():
|
||||
@auth.route('/reboot', methods=['POST'])
|
||||
@jwt_required()
|
||||
def reboot():
|
||||
''' Handles HTTP requests to URL: /api/configurateur/alive
|
||||
''' Handles HTTP requests to URL: /api/configurateur/reboot
|
||||
'''
|
||||
current_app.logger.info("Reboot du système ...")
|
||||
current_user = get_jwt_identity()
|
||||
@@ -175,6 +175,26 @@ def reboot():
|
||||
unset_jwt_cookies(content)
|
||||
return content, status.HTTP_200_OK
|
||||
|
||||
@auth.route('/shutdown', methods=['POST'])
|
||||
@jwt_required()
|
||||
def reboot():
|
||||
''' Handles HTTP requests to URL: /api/configurateur/shutdown
|
||||
'''
|
||||
current_app.logger.info("Arrêt du système ...")
|
||||
current_user = get_jwt_identity()
|
||||
userpath = os.path.join("/tmp", current_app.config['PROJECT'])
|
||||
if os.path.exists(userpath):
|
||||
shutil.rmtree(userpath)
|
||||
|
||||
reboot_cmd = ['sudo', '/usr/bin/systemctl', 'poweroff']
|
||||
if not execute_cmd(reboot_cmd):
|
||||
abort(status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
description='Arrêt du système impossible')
|
||||
|
||||
content = jsonify({'message': 'shutdown successful !'})
|
||||
unset_jwt_cookies(content)
|
||||
return content, status.HTTP_200_OK
|
||||
|
||||
@auth.route('/userConnected', methods=['GET'])
|
||||
def user_connected():
|
||||
''' retourne "oui" si un utilisateur est déjà connecté sinon "non"
|
||||
|
||||
Reference in New Issue
Block a user