Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a few new things to the makeHAB script #8

Open
Rick-Jongbloed opened this issue Mar 18, 2017 · 6 comments
Open

Added a few new things to the makeHAB script #8

Rick-Jongbloed opened this issue Mar 18, 2017 · 6 comments

Comments

@Rick-Jongbloed
Copy link

Rick-Jongbloed commented Mar 18, 2017

Hi,

i've added a few new things to my makeHAB script, which might be nice for the general script:

1: Check for root at the beginning of the script)
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi

2: Shutting down the openhab service after the files have been downloaded

# Shutting  down openhab2 service
service openhab2 stop

3: setting permissions correctly so the service runs correctly after all the files have been placed.

# Set permissions to user openhab
chown $SERVICEUSER:$SERVICEUSER  /opt/openhab2 -R

4: Starting the openhab service

# Starting openhab service
service openhab2 start

If you think these enhancements are too specific, please close this issue.

@xsnrg
Copy link
Owner

xsnrg commented Mar 23, 2017

Hi, thanks for the ideas!

  1. I don't run openHAB as root, and I would recommend that nobody else ever run it as root either. If the permissions are set correctly on devices and on the openHAB filesystem stack, running as root is not needed. It is a security issue. If 3. below was the thought for running as root, an option would be to run it as a sudo command, then the user has an option of allowing it, or password entry prompt for elevated privs to run the chmod/chown. Same for the service handling in 2. and 4.

  2. This works only if you have installed openHAB to run as a service. I am okay with shutting it down, as it should not be running when this script is executed, but we should probably check to see if it is a service, then shut the service down, else shut it down with a simple kill for folk running it in the foreground, in screen, or nohup'd.

  3. Setting the owner is good. We can set a variable at the top for the user to run as. Also, see the comment in 1.

  4. How about setting a variable in the script that the user can set if they want to auto-restart?

Thoughts?

@Rick-Jongbloed
Copy link
Author

Hi, you're welcome. I'll reply per item:

  1. I don't run openHAB as root, but i install openhab as root, and set the permissions later on. This way i never have permission issues when downloading or installing de new openhab binaries. To prevent myself accidentally running the script, while i didn't do a Sudo, i've implemented this line. We could make it optional of course.

  2. I do run openHAB as a service, maybe this should be optional as well?

  3. Yup, setting the owner is needed when running the makeHAB script as root.

  4. Thats also good. I also do a tail -f /opt/openhab2/userdata/logs/openhab.log, in the end.

Shall i have a look how to implement these changes?

@xsnrg
Copy link
Owner

xsnrg commented Apr 3, 2017

Certainly. PRs are always welcome.

@Rick-Jongbloed
Copy link
Author

I dídn't make a PR because i have to find out how that works. :-)

However one addition to get it working properly: You'll have to remove the file org.ops4j.pax.url.mvn.cfg, otherwise the repository changes won't be processed. (See https://community.openhab.org/t/karaf-console-bundle-uninstall-and-bundle-update-not-running-as-expected/27444/22)

@xsnrg
Copy link
Owner

xsnrg commented Jun 20, 2017

also of note: openhab/openhab-distro#299 (comment)

It might be time to join forces and work with that one.

@sihui62
Copy link
Contributor

sihui62 commented Nov 15, 2017

It might be time to join forces and work with that one.

Maybe, but would that (new) script work with manual installations? I can only see folder names related to an apt-get install ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants