Shell install script

Posts from previous Beta sessions

Shell install script

Postby PleegWat » Sat Dec 08, 2007 9:57 pm

Since I had nothing to do at work yesterday, I wrote the attached script. It will fetch the last roster version from the site or SVN and install it. It can also install an existing (extracted) roster.

Tested on linux, should work on most unix variants, as well as mac osx

Usage:
- Upload to your desired roster install directory on your webserver
- Log in to your webserver, and cd to the correct directory
- unzip (gunzip install.sh.gz)
- set executable (chmod +x install.sh)
- run (./install.sh)
- answer the questions
- press ctrl-C to abort the process if needed.
Attachments
install.sh.gz
Shell install script for roster
(2.59 KiB) Downloaded 253 times
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Shell install script

Postby boyo » Sun Dec 09, 2007 9:39 am

Nice idea, but what about those of us who have no access to a shell?
Any chance of writing one in php that does pretty much the same thing? Download the package, extract it and redirect to the installer.
boyo
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 103
Joined: Wed Jan 24, 2007 7:37 am

Shell install script

Postby PleegWat » Sun Dec 09, 2007 8:16 pm

Adds a lot of complication. Besides that people expect more layout from a php install script, there's a lot of overhead in handling the script reload after each user input question, more data validation, more overhead in valid output, etc. Plus a php script runs under the web server user, who is much more likely to not even have the permissions needed to do this.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Shell install script

Postby boyo » Mon Dec 10, 2007 3:19 pm

Not saying it will work 100% of the time, but like with SMF you can upload one file, webinstall.php and it will do the rest.

You can see what I was talking about here
boyo
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 103
Joined: Wed Jan 24, 2007 7:37 am

Shell install script

Postby Diska » Fri Dec 14, 2007 8:13 pm

I hadn't really gotten round to fully testing the install script, but I did today, and I had 3 problems with it.

1. After completing the script (clean install!) and browsing to the new roster I had to "upgrade" which gave me an error about inserting a version key into the roster_config which already existed. I added the following code to have the install script insert the version number:

Code: Select all
version=`cat version.txt | cut -f2 -d\> | cut -f1 -d\<`

$MYSQL << !
UPDATE \`${db_prefix}config\` SET \`config_value\` = '${version}' WHERE \`config_name\` = 'version';
!


I'm pretty sure the extraction of the version number from version.txt can be done in a nicer way with regexps but that's one of my underdeveloped qualities ;)

2. The stored password wouldn't work. Neither the password in typed myself or the "admin" password that's stored in the install.sh. I worked around this by modifying the code to use the md5() function of mysql. This also removes the dependency on the external md5sum program:

Code: Select all
# Password setting
while :
do
        read -s -p "Please enter your desired password: " pass1
        echo
        read -s -p "Please confirm your password: " pass2
        echo
        if [ ${pass1} == ${pass2} ]
        then
                break
        fi
        echo 'Your passwords did not match. Please retry'
done

$MYSQL << !
INSERT INTO \`${db_prefix}account\` (\`account_id\`,\`name\`,\`hash\`) VALUES
(1,'Guild', md5('${pass1}')),
(2,'Officer', md5('${pass1}')),
(3,'Admin', md5('${pass1}'));
!


3. I'm getting a 404 on the interface_latest.tar.gz
Last edited by Diska on Fri Dec 14, 2007 8:31 pm, edited 1 time in total.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Shell install script

Postby PleegWat » Fri Dec 14, 2007 8:42 pm

1: Sorry, incorrect assumption (and lack of testing) on my side. I assumed we were updating the version number in the SQL file as well, while we aren't.
2: I'm pretty sure I verified it produced correct md5 hashes. I didn't know about the mysql function.
3: Zanix said he'd put those files there, but apparently he hasn't. Unfortunately, I don't have access there myself.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Re: Shell install script

Postby Diska » Fri Dec 14, 2007 8:55 pm

PleegWat wrote:2: I'm pretty sure I verified it produced correct md5 hashes. I didn't know about the mysql function.


It does, the md5sums are entirely correct, that's the weird part. I verified the values that were inserted into the database, and they were equal to my test on the commandline. It still wasn't working though.
Hmm, now that I'm giving it more thought, could it be a newline character in the password variable? I used "echo <password> | md5sum" to check, not "echo -n <password> | md5sum"
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Shell install script

Postby PleegWat » Sat Dec 15, 2007 6:16 am

Could be. Doing it in mysql is less hassle anyway.

I just created the .tar.gz files for the wget install method.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm


Return to Archived

Who is online

Users browsing this forum: No registered users and 1 guest

cron