Can we run a --before-install script as standard user, and not as root?

Skip to first unread message


Mar 7, 2017, 12:46:45 PM3/7/17
to fpm-users
I'm trying to use script before and after install to further automate my release.
however, the scripts --before-install and --after-install are run as root.

I need to run the script as the current user.
indeed I need to create folders in home/my_current_user/
I also need to execute some installed program that require the current bash context and variables...

Is that possible?

I've tried using within the script the $SUDO_USER variable
Also sudo su -c "mkdir -p ~/folder/src; cd ~/folder/src; catkin_init_workspace " -s /bin/sh $SUDO_USER

This way we achieve "some" limited things: the folder is created correctly but the "catkin_init_workspace" installed executable do not have the necessary environment variables to run.
we usually need (as user), to source a specific from an /opt/ program

any idea how to advance?


Daniel Jay Haskin

Mar 8, 2017, 9:56:26 AM3/8/17
That's not the intended use case of system packages.

System packaging systems, such as rpm or Debian, are intended to package software for distribution to other Linux machines. It is very much a feature that they install files and run scripts as the root user. What you are doing sounds more closely aligned to what configuration management software, such as puppet or SaltStack, might be used for.
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Reply all
Reply to author
0 new messages