tobychui / arozos

Web Desktop Operating System for low power platforms, Now written in Go!
http://arozos.com
GNU General Public License v3.0
1.87k stars 138 forks source link

[Optimization] Installer - sudo missing #130

Closed radim-ek closed 2 months ago

radim-ek commented 1 year ago

Installer use "sudo" in Linux. But sometimes there is not "sudo" and user is under root. And therefore not created systemd service. And ./start.sh" not worked too.

--------"SCREENSHOT" of comand line BELOW ---------

Do you want to install ArozOS to systemd service? (y/n)y install.sh: line 133: sudo: command not found install.sh: line 134: sudo: command not found install.sh: line 154: sudo: command not found install.sh: line 157: sudo: command not found install.sh: line 158: sudo: command not found install.sh: line 159: sudo: command not found ArozOS installation completed!


tobychui commented 1 year ago

Hi @radim-ek , thanks for the feedback. I am not too familiar with bash scripting. I am thinking if there are any better ways to do it other than including apt-get install sudo into the installer script. You got any recommended way for me to improve it?

Morethanevil commented 1 year ago

Those lines are for the systemd service. You can create this yourself easily. Run the installscript and ignore the warnings. Now run create a new service file as root:

nano /etc/systemd/system/arozos.service

Put in these lines to run arozos:

[Unit]
Description=ArozOS Cloud Service
After=systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
WorkingDirectory=/home/${CURRENT_USER}/arozos/
ExecStart=/bin/bash /home/${CURRENT_USER}/arozos/start.sh

Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Now (still as root) start Arozos with:

systemctl enable --now arozos.service

You can check the status with:

systemctl status arozos.service

neonspectra commented 5 months ago

@tobychui A highly portable drop-in replacement for using sudo (if you really need root) is:

su - root -c "yourcommand"

Explanation:

Note: it's still possible for this to not work if the system you're running on doesn't have root access at all, like some weird ARM stuff (which is I think the target for a lot of this project). But that's probably outside the scope of troubleshooting and if someone runs into that issue, they need to root their device.


Also, it's generally better practice to use sudo than su since you can't enforce granular permissions via sudoers in su the way you can via sudo. Best practice, however, is to not require root.

tobychui commented 5 months ago

@neonspectra Thanks for the tips. In fact ArozOS can work without root, but if that is the case, it pretty much just serve as a web desktop interface like other front-end only projects. To run arozos without root, just download the web.tar.gz and the executable into any folder and run it with ./arozos.

Root access is required for disk management (SMART / disk mounting), WiFi utilities and more to make ArozOS useful so to say. Though, making the installer sudo optional is not a high priority task so I just leave this here for now. As usual, PRs are welcomed!

tobychui commented 2 months ago

Closing issue as the fixes has been merged