Results 1 to 5 of 5
I'm writing an installation script that has many different parts that need to be installed by the user that is executing the script and certain parts need to be executed ...
- 08-26-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 10
Store user name when executing a bash script as sudo?
I'm writing an installation script that has many different parts that need to be installed by the user that is executing the script and certain parts need to be executed with sudo and other parts require me to install them as the user so that they end up installed in the correct location. The problem is that I have too many items being installed either way for me to pick either requiring a password for each sudo apt-get item (or anything that modifies system files). So ideally, I'd like the script to know how to go about doing this and have the user change temporarily for each menu option that requires it.
Also, is there any way to carry this across multiple script files?
tl;dr:
Here's my code and the code I'm trying to install:
#1 and #2 are mine, #3 is something that I'm trying to incorporate into my installer and having trouble because I can't get root to drop and his files are installed into the /home/root directory. Whenever I have it install I'd ideally want it to install into their /home/username/.... directory.
#1 gist.github com/fe8760fa481b8b474601
#2 gist.github com/2a6a0a5489d25924028b
#3 gist.github com/663f586192245f055c40
- 08-26-2011 #2
Is there no way that you can do all the root stuff at the start/end, and then all the user stuff so you only get asked once?
If that's not the case, then you could maybe look into something like Expect. This will allow the user to specify a password in the script, and it will then automatically be able to use this as/when it needs."I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 08-26-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 10
Based on the nature of what I need to let the users choose from installing, I don't think I can do all the root installation parts first. My main goal is to make a very broad installation script for Android community themers / developers that lets them choose what they want to install depending on their needs at the time and to try to include as many things as possible in the script through menus for them. The problem with this is that I've begun assimilating other scripts that don't require root like mine did and that's where I'm getting confused. I've been asking the Android community what they use, then asking the script writers for their permission to include it in my script, and then trying to modify their scripts and just running into a few road blocks along the way with the permissions with root/normal user during the setup processes of their scripts.
- 08-26-2011 #4
I looked briefly over your three scripts.
To be honest, I would approach that differently.
Everything, that needs to be system wide should be packaged (deb in your case)
Everything that shall live in a home directory should be available via a repository. svn/git/whateverYou must always face the curtain with a bow.
- 08-26-2011 #5Linux Guru
- Join Date
- May 2011
- Posts
- 1,842


Reply With Quote
