How to switch installer to superuser

Answered

Comments

5 comments

  • Avatar
    wojciechka

    One option is to run gksu or kdesu when detecting the installer is not run as root. For example:

    <initializationActionList> <actionGroup> <actionList> <throwError text="Please, launch the installer as root"> <ruleList> <programTest name="gksu" condition="is_not_in_path"/> <programTest name="kdesu" condition="is_not_in_path"/> </ruleList> </throwError> <runProgram program="gksu" programArguments="${installer_pathname} &amp;" > <ruleList> <programTest name="gksu" condition="is_in_path"/> </ruleList> </runProgram> <runProgram program="kdesu" programArguments="-c ${installer_pathname} &amp;" > <ruleList> <programTest name="gksu" condition="is_not_in_path"/> <programTest name="kdesu" condition="is_in_path"/> </ruleList> </runProgram> <exit/> </actionList> <ruleList> <isFalse value="${installer_is_root_install}"/> </ruleList> </actionGroup> </initializationActionList>

    This will restart the installer using kdesu/gksu if any of them are in path and will throw an error (which will show a graphical dialog or print the error on console for text mode) if none of the commands are found.

  • Avatar
    tahoar

    I updated the code slightly to return any exit code to the shell.

    <initializationActionList>
        <actionGroup>
            <actionList>
                <throwError text="Please, launch the installer as root">
                    <ruleList>
                        <programTest condition="is_not_in_path" name="gksu"/>
                        <programTest condition="is_not_in_path" name="kdesu"/>
                    </ruleList>
                </throwError>
                <if>
                    <actionList>
                        <runProgram program="gksu" programArguments="${installer_pathname} &amp;"/>
                    </actionList>
                    <conditionRuleList>
                        <programTest condition="is_in_path" name="gksu"/>
                    </conditionRuleList>
                    <elseActionList>
                        <runProgram program="kdesu" programArguments="-c ${installer_pathname} &amp;"/>
                    </elseActionList>
                </if>
                <exit exitCode="${program_exit_code}"/>
            </actionList>
            <ruleList>
                <platformTest negate="1" type="windows"/>
                <isFalse value="${installer_is_root_install}"/>
            </ruleList>
        </actionGroup>
    </initializationActionList>
    
  • Avatar
    Frank Ernesto Matos

    hi this is very similar to what I was looking for but I´m having the next problem: the gksu is prompting well but when i put the root password correctly it desappear and the other screens of the installer are never shown. I´m working with the second code. Another: ¿what really the program_exit_code does ?

  • Avatar
    Frank Ernesto Matos

    In this line <runprogram program="gksu" programarguments="${installer_pathname} &amp;"/> what the & is for??

  • Avatar
    andny

    gksu is now deprecated. I changed to this.

    <actionGroup>
        <actionList>
            <throwError text="Please run the license initialization script as root after the installation">
                <ruleList>
                    <programTest condition="is_not_in_path" name="pkexec"/>
                </ruleList>
            </throwError>
            <runProgram program="pkexec" programArguments="${license_init_script}">
                <ruleList>
                    <programTest condition="is_in_path" name="pkexec"/>
                </ruleList>
            </runProgram>
        </actionList>
        <ruleList>
            <isFalse>
                <value>${installer_is_root_install}</value>
            </isFalse>
        </ruleList>
    </actionGroup>
    

Please sign in to leave a comment.