Gentoo Distro isn't recognized with Control pnel (Also patches for functions/services) #339

Open
ghost opened this Issue Nov 18, 2012 · 3 comments

Projects

None yet

2 participants

@ghost

Hey all, Drew said I should follow up with a post here ( http://answers.preyproject.com/topics/modified-functions-services-under-platform-files )

While working with the prey ebuild on gentoo, I uncovered some issues with functions/services. The patches are below, but the biggest issue now is that when the patches are applied, a Gentoo device cannot be added as the control panel does not recognize the "Gentoo" distro. I'm going to do a small patch for the gentoo ebuild that just pretends it's arch for the time being.

Here's the patches:

prey/platform/linux/functions

--- functions.old       2012-11-18 12:43:59.000000000 -0500
+++ functions   2012-11-18 13:02:10.009071216 -0500
@@ -87,9 +87,16 @@
 ############################################

 # echoes 1 if prey trigger is set
-# TODO: check if this works in other distros beside the Debian derivatives
+# TODO: This should work on most major distros/derivatives, but as below, there's probably
+# a better way of doing this.
 is_trigger_loaded(){
-       find /etc/rc3.d/ | grep 'prey-trigger' > /dev/null && echo 1
+       if [ -d "/etc/rc3.d" ]; then
+               find /etc/rc3.d/ | grep 'prey-trigger' > /dev/null && echo 1
+       elif [ -d "/etc/init.d" ]; then
+               find /etc/init.d/ | grep 'prey-trigger' > /dev/null && echo 1
+       elif [ -d "/etc/rc.d" ]; then
+               find /etc/rc.d/ | grep 'prey-trigger' > /dev/null && echo 1
+       fi
 }

 reload_trigger(){
@@ -146,23 +153,25 @@

        [ -n "$distro_name" ] && return 1

-       local proc_version=$(cat /proc/version 2>&1)
+       proc_version=$(cat /proc/version)

        # todo: make this in a more efficient way
-       if [ -n `find_in $distro 'Ubuntu'` ]; then
+       if [[ "$proc_version" == *Ubuntu* ]]; then
                distro_name=ubuntu
-       elif [ -n `find_in $distro 'Debian'` ]; then
+       elif [[ "$proc_version" == *Debian* ]]; then
                distro_name=debian
-       elif [ -n `find_in $distro 'Redhat'` ]; then
+       elif [[ "$proc_version" == *Redhat* ]]; then
                distro_name=redhat
-       elif [ -n `find_in $distro 'Fedora'` ]; then
+       elif [[ "$proc_version" == *Fedora* ]]; then
                distro_name=fedora
-       elif [ -n `find_in $distro 'CentOS'` ]; then
+       elif [[ "$proc_version" == *CentOS* ]]; then
                distro_name=redhat
-       elif [ -n `find_in $distro 'SuSE'` ]; then
+       elif [[ "$proc_version" == *SuSE* ]]; then
                distro_name=suse
-       elif [ -n `find_in $distro 'ArchLinux'` ]; then
+       elif [[ "$proc_version" == *ArchLinux* ]]; then
                distro_name=arch
+        elif [[ "$proc_version" == *Gentoo* ]]; then
+                distro_name=gentoo
        else
                distro_name=linux
        fi


prey/platform/linux/services

 services.upstream.patch                                                                                      

--- services.old        2012-11-18 12:43:59.000000000 -0500
+++ services    2012-11-18 13:04:38.649372692 -0500
@@ -18,9 +18,10 @@
 linux_copy_init_script(){
        local full_init_script_path="$1/$2"
        if [ ! -e "$full_init_script_path" ]; then
-               ln -s "$(full_path $base_path)/${platform_path}/${2}" "$full_init_script_path" 2> /dev/null
+               ln -s "${platform_path}/${2}" "$full_init_script_path" 2> /dev/null
                local retval=$?
                [ $retval != 0 ] && log " !! Couldn't copy init script into ${1}!"
+               chmod +x "${platform_path}/${2}"
                return $retval
        fi
        return 0
@@ -81,3 +82,15 @@
 arch_unload_service(){
        linux_remove_init_script '/etc/rc.d' $1
 }
+
+gentoo_load_service(){
+       linux_copy_init_script '/etc/init.d' $1
+       rc-update add prey-trigger default
+}
+
+gentoo_unload_service(){
+       rc-update delete prey-trigger 
+        linux_remove_init_script '/etc/init.d' $1
+}
+
@tomas
Prey member

Hi pryoidain,

Thanks for the patch! I'll merge your code in a minute. I also added Gentoo as a valid OS/distro in the Control Panel, but I need a list of versions along with their names to show in the combobox (the number should match what the lsb_release -r -s command returns).

@ghost
@jristz

Sorry but the init that is used for ArchLinux is deprecated in favor of systemd (used by fedora and opensuse and now by ArchLinux)
but is used on ConnochaetOS and CRUX (the rc.d/initscript schema)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment