LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2012, 11:17 PM   #1
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
how to get user to agree to EULA in bash script?


Hi

I intend to write a package, actually its a tinycore package that encloses an EULA from a third party.

its a text file.

I lack the skills on how to enforce the reader to read the text and then type "I accept" and "reject"

2) It would be handy that this script also produces a file such as
/home/yourname/EULA/accepted (or rejected)

That way, I can make a simple if-then script that searches for this new file.
-if accepted found....do some work
-if rejected found....call up aterm or some terminal and re-submit the EULA to the end user

Any clues greatly appreciated

As my skills are not so great to ask, feel free to be verbose

cheers

Gordon
 
Old 12-14-2012, 11:42 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I am not sure I understand the complexities Surely you write an if to check for the files, if none get response and if file perform appropriate task.

So is your question that you do not know how to do an 'if' in bash?
 
Old 12-14-2012, 09:27 PM   #3
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Original Poster
Rep: Reputation: Disabled
deleted later post

Last edited by aus9; 12-20-2012 at 01:01 AM.
 
Old 12-15-2012, 04:51 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
hmmmm ... well there are a few issues but the most glaring would be an assumption you have made:
Code:
# if here, agreement confirmed
/usr/local/bin/pepper
As the only exit in the entire code is on checking for the root user (testing $USER may need to be looked at), the above is completely wrong as nothing
else stops you from getting here.
 
Old 12-20-2012, 12:59 AM   #5
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Original Poster
Rep: Reputation: Disabled
Thanks lets try mark II

Last edited by aus9; 12-20-2012 at 01:11 AM.
 
Old 12-20-2012, 01:02 AM   #6
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Original Poster
Rep: Reputation: Disabled
re-wrote as

Code:
#!/bin/sh                                                   
if [ "$USER" == "root" ] ; then                             
  echo "Run as non-root please, exiting."                     
  exit 1                                                     
  fi                                                          

# set the local user to $THISUSER                          
THISUSER=`cat /etc/sysconfig/tcuser`                        

echo "This plugin has an EULA that needs your consent"      
echo "if you use it, you grant consent as well"             
echo "after reading the agreement please close the browser" 
/bin/sleep 6                                                
chromium-browser /usr/local/share/doc/pepper/eula_text.html 
echo "Do you accept the EULA? type  yes  or no   please"    
read input                                                 

if [ $input = yes ] ; then                                  
# agreement confirmed                                       
# refresh OR create agreement file status                   
rm -r -f /home/$THISUSER/.pepper                            
mkdir /home/$THISUSER/.pepper                               
touch -f /home/$THISUSER/.pepper/agreed                     
   else                                                    
   echo "agreement refused, exitting"                       
   rm -r -f /home/$THISUSER/.pepper                         
   exit 1                                                   
   fi

Last edited by aus9; 12-20-2012 at 01:10 AM.
 
Old 12-20-2012, 05:48 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well starting at the top, I would probably use the 'id' command instead of the variable as someone may set it on the command line to something else (if we assume someone is being naughty).

I am not understanding the point of the THISUSER? What I mean is, unless you are root you will not be able to go into another user's account (generally) so if
it is in 'this user' , ie the logged in user, why not simply use $USER, id or even '~' (synonym for home directory)??

I am next a little dubious about firing off a browser, does the accepting of the agreement close the browser?

You are testing your 'input' variable against a set string, "yes", what if the user enters "y" or "Yes"?

Irrelevant of the user's reply yuou do the following:
Code:
rm -r -f /home/$THISUSER/.pepper
I have 2 issues here:

1. If it is a given this will always occur then simply do it prior to testing 'input'

2. You never check to see if the directory actually exists and in the case of the 'else', ie likely the first time this has been run and the says "no", the user will now be presented with an error
from rm saying no such directory

Hope some of this helps
 
Old 12-20-2012, 02:08 PM   #8
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
Frankly, trying to do EULA install enforcement in a shell script is kind of pointless since it's so easy to bypass.
 
  


Reply

Tags
eula bash script



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
switching user with bash script Gil@LQ Linux - Software 1 01-14-2012 08:45 AM
Switch user in a bash script bribon Programming 7 07-29-2011 09:33 AM
super user privileges check for a normal user in bash script freeindy Programming 2 08-01-2008 06:08 AM
add user bash script noir911 Programming 4 08-13-2005 08:24 AM
how to change user in bash script c0d3 Programming 6 07-27-2005 11:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration