leader21 / pimatic-installer

Installation program for installing Pimatic, Homeduino and additional programs
5 stars 2 forks source link

Should check for sudo and or root.. #3

Open demlak opened 8 years ago

demlak commented 8 years ago

Hi, i was using the installer last night.. and it needs some things that it don´t check.. for example sudo..

as im using a minimal debian installation, sudo wasn´t installed by default..

a little check about installed sudo or if the current user is root, would be nice..

leader21 commented 8 years ago

well yes, the installer was usually designed for the regular image. i will look into that and see what i can do.

mwittig commented 8 years ago

@demlak As you are apparently familiar with open source development why don't you look into this and make a pull request?

demlak commented 8 years ago

well.. since im not a coder... and im not familiar with this git things.. i just thought a check for sudo and/or root should be easy for a coder...

i have to use google to "steal" code from different sites and put this together.. here is a check for root and sudo... i don´t know how to integrate it, so that the installer script announces a problem to screen and log, if both are not present:

http://stackoverflow.com/a/21622456

leader21 commented 8 years ago

@demlak which distribution are you using exactly? the jessie lite should have sudo installed from scratch and user pi has permanent sudo permissions as far as i was able to check for now.

it needs some things that it don´t check.. for example sudo..

what other issues are you talking about

demlak commented 8 years ago

it was late last night.. im not 100% sure, if missing python was related to the install script.. or to pimatic itself.. or to a plugin.. but i needed it...

im using this jessie version: https://github.com/debian-pi/raspbian-ua-netinst

mwittig commented 8 years ago

@leader21 Another note: To check if sudo is installed you you can do something like described in the following post http://www.cyberciti.biz/faq/find-out-if-package-is-installed-in-linux/

Another approach is to simply call "sudo -h" and then check the execution status

Try sudo -h ; echo $? Result 0 means no error. Any other number is an error.

The following snippet should do

sudo -h >/dev/null 2>&1
if [ $? -eq 0 ]; then
        echo "OK"
else
        echo "Not Found"
fi

Make sure have spaces inside the [ ] expression. Otherwise, you will get an syntax error

leader21 commented 8 years ago

Thanks @mwittig well it seems there are some more lite versions available. The installer should be for easy install and easy to use for beginners and advanced user surely too.

from my actual point of view its an overkill for the script to check every possibility for missing packages or dependencies when using lite images or other distributions then raspbian. it's still a "simple" bash script... that's why I recommend to use either raspbian Jessie or Jessie lite (without x support). These are tested an will work without issues. The sudo check could be useful if using other images. I'll try to implement it in the next version.