Heyas
Guess its time again to use more brainpower and experience

As i try to write my script collection to be able to use (many) diffrent distros, not only fedora, i face very diffrent syntax for some commands.. example.. yum, apt-get, pacman
My first attempt in getting soem basic system recognation, was to parse /etc for files named *-release or *-version.
That was semi successfull, all redhat based system worked well, as well as debian itself and arch.
However, Ubuntu and its derivates dont work the same way.
Well, in ubuntu i would find a debian-version, would would let me know i had to use apt-get rather than yum.
However, it doesnt tell me its ununtu, or which version of ubuntu.
lsb-release was another approach, but, since i want to run my scripts without installation required (yet it still needs), i'd have to implement some sort of checking if its available. and install it then 'accordingly' which results a problem, as i dont know which installation syntax is required.
Now to give you an impression of how confused i'm currently are regarding this topic, here are the current code segments: ( / refers to the script base, not the root dir)
/system/filesystem:
PHP Code:
(....)
seayum() {
if isHelpy "$1" ; then echo $HelpYum && return 1 ; fi
desc=$1
pack=$2
#isFedora
if isFedora
then seaaction "Installing" "sudo yum install" "$desc" "$optYum" "$pack" && return 0 || echo "Fedora wrong system?"
elif isUbuntu
then seaaction "Installing" "sudo apt-get install" "$desc" "$optAptGet" "$pack" && return 0 || echo "Ubuntu wrong system?"
else seaecho "Cant examine system..." "Assuming ARCH"
seaaction "Installing" "sudo pacman" "$desc" "-S" "$pack" && return 0 || echo "# | Cant handle this system"
fi
}
(.....)
/system/release
PHP Code:
redhatstyle=/etc/system-release
isFedora() {
if test -f /etc/fedora-release
then return 0
else return 1
fi
}
isUbuntu() { # FAILS, obsiously if lsb-release is not isntalled
if [[ "$(release)" | grep "buntu" ]]
then return 0
else return 1
fi
}
release() {
getReleaseID() { echo $(lsb_release -is) ; }
getReleaseNum(){ echo $(lsb_release -rs) ; }
getReleaseCN() { echo $(lsb_release -cs) ; }
#Desc=$(getReleaseDescr) >/dev/null 2>&1
Distro=$(getReleaseID) >/dev/null 2>&1
Ver=$(getReleaseNum) >/dev/null 2>&1
CN=$(getReleaseCN) >/dev/null 2>&1
if test ! "" = "$Distro" & test ! "n/a" = "$Distro"
then output="$Distro "
elif -f /etc/fedora-release
then cat /etc/fedora-release
return 0
elif -f /etc/system-release
then cat /etc/system-release
return 0
elif [[ ! "$isUbuntu" = "1" ]]
then output="Ubuntu "
return 0
fi
if test ! "" = "$Ver" & test ! "n/a" = "$Ver"
then output="$output$Ver " ; fi
if test ! "" = "$CN" & test ! "n/a" = "$CN"
then output="$output$CN " ; fi
if is64bit ; then output="$output(64 bit) " ; fi
echo $output
return 0
}
releaseVer() {
echo $(release) | grep -ow -E [[:digit:]]
}
/system/sea.gui
PHP Code:
# just while posting an idea came up, creating a file named..
# a.sh or something, so this part *should* be read as first??
if ! [[ tmplsb=$(lsb_release -v) ]] ; then
echo "LSB-Release is missing, installing..."
test sudo -y -q lsb-release
test sudo apt-get install lsb-release
test sudo pacman -S --noconfirm lsb-release
fi
sleep 5
I'm thankfull for every idea.