How to addGroup and copy files to root of Linux system

Comments

2 comments

  • Avatar
    juanjo

    If the only problems you are finding about running with sudo are file permissions, I would recommend detecting the logged in user and fixing them afterwards:

    <setInstallerVariable>
        <name>current_username</name>
        <value>${system_username}</value>
    </setInstallerVariable>
    <setInstallerVariable>
        <name>current_username</name>
        <value>$env(SUDO_USER)}</value>
        <ruleList>
            <compareValues>
                <logic>equals</logic>
                <value1>${current_username}</value1>
                <value2>root</value2>
            </compareValues>
            <compareTextLength>
                <length>0</length>
                <logic>greater</logic>
                <text>${env(SUDO_USER)}</text>
            </compareTextLength>
        </ruleList>
    </setInstallerVariable>
    ...
    <runProgram program="chown" programArguments="-R ${current_username} &quot;${installdir}&quot;"/>
    Or
    <runProgram program="chmod" programArguments="-R 755 &quot;${installdir}&quot;"/>
    <runProgram program="chmod" programArguments="-R 777 &quot;${installdir}/folderRequiringWriting&quot;"/>
    

    This would simplify the installation logic and will avoid errors because of the extra complexity.

    If that would not fit your needs and wan't o implement your suggested approach, we do not support executing specific actions with elevation but you could create an script with all the required actions requiring admin privileges:

    #!/bin/bash
    useradd -G group1,group2 someuser
    ...
    

    And then use a <runprogram> to call gksudo or kdesudo:

    <runProgram program="gksudo" program="${installdir}/yourscript.sh"/>
    
    0
    Comment actions Permalink
  • Avatar
    ChaseMaupin

    juanjo,

    Thank you for the response. What I ended up doing was moving the functionality that I needed sudo access for into a script that would run after the install. I added a password prompt into the installer for the sudo password and feed that to my script using the sudo -S syntax.

    Chase

    0
    Comment actions Permalink

Please sign in to leave a comment.