Server Restart Option

Would like to see a 'Server Restart' option in the Cog dropdown menu just above the Logout. Also add this as a permission in the User Accounts so we can disable that option from users. This would make it easier to restart the server while using the web ui remotely.

Comments

  • This is already possible. See manual -> Advanced Setup. It describes how to reboot or shutdown pi. Same method can also be used to restart the server service.
  • Reading that document states that it would allow possible hacking and its not a secure way. I don't mind using a script as long as it can be set up to be used by approved users.

    If not, then having it built into the server with user access limited to those approved would be the only other option that I can think of.
  • What I meant is that everyone with access to server can run it, but since it is not configurable from server it is safe. I mean it only restarts the server so it is all they can do. Also you can add a confirm dialog and set required user permission so it is as safe as it can be. Making it editable from internet would make it insecure.
  • Maybe I am getting a bit confused here, not explaining the request or just not understanding what you mean by using a script. So I will try to better clarify the request along with trying to clarify my understanding of the script that was mentioned.

    What I am looking for is an addition to the User Profile (within Rep-Server) in the Edit Profile window to allow for selected profiles the ability to restart the daemon (service). I don't want the hardware restarted, just the daemon (service). Since I am not well versed in scripting within Ubuntu, I am making a guess that different OS versions would use different scripts to restart the Daemon service for Rep-Server. I believe this variety of script differences could be resolved by adding a Script section in Global Settings allowing an Administrator user in Rep-Server to be able to edit the script to fit the OS version they are using. Then that script would show up as an option in the Edit Profile window.

    Now for my confusion on the information about a script that you recommended. I am not sure where within Rep-Server you can place a script. I read the document and I am making a guess that what is being recommended is making an OS side script outside of Rep-Server. That is not what my request involves. If I had to run the script from within the OS, then I wouldn't need a script since I could just as easily reboot the server if needed.

    The whole point of the request is to have a quick and easy way to remotely restart the Rep-Server daemon while I am not near the equipment. Or in between prints, quickly restart the daemon to refresh the Rep-Server.

    Hope that helps in clarifying the request... sometimes I have an idea in the mind and just can't get it across in my text.
  • Ok, so I understood you correctly:-)

    extcommands.xml is to be placed in storage database directory, on linux /var/lib/Repetier-Server/database.
    The command for restarting server is
    /usr/bin/sudo service  service RepetierServer restart
    Here the correct example from docs with hidden parts:

    <config>
    	<!--
           If you want to run external commands, enter them in this configuration with
           full path. You will see them in the main menu. Copy this file into the
           <storage>/database directory.
    
           Security consideration: The reason there is no online editor for this is simply
           security. The commands you enter here are executed with the privileges of the
           daemon running the server. If you would allow online configuration, a hacker could
           simply add any command he needs to hack your system.
    
    	     Commands are normally visible in the global menu. If you want one to appear only in
    	     in the printer menu, add the attribute "slugname" to command. You see the slugname
    	     when you select a printer as part of the path.
        -->
    	<command>
    		<name>Shutdown Server</name>
    		<execute>sudo /sbin/shutdown -h now</execute>
    		<confirm>Really shut down the server?</confirm>
    	    <!-- Define if command should show up in local printer interface, default true.-->
    		<local>true</local>
    	    <!-- Define if command should show up in remote printer interface, default true.-->
    		<remote>true</remote>
    	    <!-- Define if command should show up only for users with print permission, default true.-->
    		<print-permission>true</print-permission>
    	    <!-- Define if command should show up only for users with add files permission, default false.-->
    		<add-permission>true</add-permission>
    	    <!-- Define if command should show up only for users with del files permission, default false.-->
    		<del-permission>true</del-permission>
    	    <!-- Define if command should show up only for users with configuration permission, default false.-->
    		<config-permission>true</config-permission>
    	</command>
    	<command>
    		<name>Reboot Server</name>
    		<execute>sudo /sbin/shutdown -r now</execute>
    		<confirm>Really reboot the server?</confirm>
    	</command>
    
    	<!--
            G-code files can contain
            @execute cmd param1 param2
            commands. To prevent external users from executing unwanted or dangerous commands,
            only commands defined here are allowed to execute. More over, only the shortcuts
            defined here are to be used as cmd in @execute. Prevent parameter where ever possible.
        -->
    	<execute name="play" allowParams="true">/usr/bin/afplay</execute><!-- play the sound file on moc os x -->
    </config>
    
    As you see you can exactly where and for which user permissions it should appear.
    Just make sure user repetierserver can start sudo without password prompt.
  • Thanks! I will try this and let you know how it went. I believe I already gave repetierserver the permission to start sudo without password prompt.
  • Worked like a charm. Now only users with Configuration permissions can restart the server. Thanks!
  • edited July 2020
    can we have a way to restart the service in the GUI on our PC 
    it does not seem to restart cleanly

    how can I create a user setting that will allow "service" to be restarted
    but not restart/shutdown
    (but still have admin login that can )

    created

     /var/lib/Repetier-Server/database/extcommands.xml

    added

    <command>
    <name>Restart Service</name>
    <execute>sudo service RepetierServer restart</execute>
    <confirm>Really reboot restart service?</confirm>
    </command>



    these permissions seem to affect all execute commands in the config file globally, is their a way to separate them ?


    <!-- Define if command should show up in local printer interface, default true.-->
    <local>true</local>
        <!-- Define if command should show up in remote printer interface, default true.-->
    <remote>true</remote>
        <!-- Define if command should show up only for users with print permission, default true.-->
    <print-permission>true</print-permission>
        <!-- Define if command should show up only for users with add files permission, default false.-->
    <add-permission>true</add-permission>
        <!-- Define if command should show up only for users with del files permission, default false.-->
    <del-permission>true</del-permission>
        <!-- Define if command should show up only for users with configuration permission, default false.-->
    <config-permission>true</config-permission>



    sudo visudo
    repetierserver ALL=(ALL) NOPASSWD: ALL
    
    
    aio@aio:/var/lib/Repetier-Server$ sudo service RepetierServer status
    ● RepetierServer.service - Repetier-Server 3D Printer Server
         Loaded: loaded (/lib/systemd/system/RepetierServer.service; enabled; vendor preset: enabled)
         Active: active (running) since Tue 2020-07-21 15:28:41 AEST; 6s ago
        Process: 1370342 ExecStartPre=/bin/mkdir -p /var/lib/Repetier-Server (code=exited, status=0/SUCCESS)
        Process: 1370343 ExecStartPre=/bin/chown -R repetierserver /var/lib/Repetier-Server (code=exited, status=0/SUCCESS)
        Process: 1370346 ExecStart=/usr/local/Repetier-Server/bin/RepetierServer -c /usr/local/Repetier-Server/etc/RepetierServer.xml -->
          Tasks: 10 (limit: 77010)
         Memory: 22.8M
         CGroup: /system.slice/RepetierServer.service
                 └─1370347 /usr/local/Repetier-Server/bin/RepetierServer -c /usr/local/Repetier-Server/etc/RepetierServer.xml --daemon
    
    Jul 21 15:28:41 aio systemd[1]: Starting Repetier-Server 3D Printer Server...
    Jul 21 15:28:41 aio systemd[1]: RepetierServer.service: Found left-over process 1370337 (sudo) in control group while starting unit.>
    Jul 21 15:28:41 aio systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
    Jul 21 15:28:41 aio systemd[1]: RepetierServer.service: Found left-over process 1370338 (systemctl) in control group while starting >
    Jul 21 15:28:41 aio systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
    Jul 21 15:28:41 aio systemd[1]: Started Repetier-Server 3D Printer Server.
    Jul 21 15:28:41 aio sudo[1370337]: pam_unix(sudo:session): session closed for user root
    
    





  • On windows you have a menu entry in windows menu to start/stop the service. But see answer on other threa on why i think it is slow.
  • edited July 2020
    This is on Linux ,I am wanting a way to separate permissions to allow service to be restarted instead of it wanting to reboot my main pc ,, I want normal users to be able to restart service but not reboot / shutdown 
  • edited July 2020
     
  • sudo service RepetierServer restart

    will restart the server. Try to add this in extcommands.xml just like the reboot.
Sign In or Register to comment.