Jump to content

Recommended Posts

Hi, im new to linux and i wanted to make an install script to automate the installation of a game, but i have no idea what bash is. I was wondering if someone could help program two sections of the code i need. That would be great because the rest of the script is the same thing almost.

 

First the script checks if the user is root or not, b/c this is where the game is installed

if [ `id -u` != 0 ]
then
	destpath="${HOME}/Games/UrbanTerror4/q3ut4"
else
	destpath="/usr/local/games/UrbanTerror4/q3ut4"
fi

(this is all i can code so far)

then it downloads all the files ending in ".pk3" at this location: "http://h4x0rz.bounceme.net/Urban%20Terror/maps/" to the destpath location on the user's computer, WITHOUT overriding any files.

 

This is what i currently have that does the same job but is more manual:

cd ${destpath}/q3ut4
		maps_dl_url="http://h4x0rz.bounceme.net/Urban%20Terror/maps/"
		wget - c 'http://h4x0rz.bounceme.net/Urban Terror/maplist'
		maplst=`cat maplist`
		for map in $maplst; do
				${wget_bin} ${maps_dl_url}/${map}.pk3
		done
		rm maplist

This sucks cause i have to update the text file manually.

Edited by Deo Favente

Share this post


Link to post
Share on other sites

I'm not quite sure what you're trying to achieve. I've seen your two scripts, and I can see what they are doing. But now, I'm wanting to know, what you want to do other than what the scripts you have so far?

 

I must be missing something :unsure:

 

In the second script, what is it that you're having to update manually? Please explain, so we can help put the script together.

Share this post


Link to post
Share on other sites

It appears that there is nothing in the remote directory but .pk3 files, so there is no need for the maplist, really.

As Greg2 said, this command will do it for you (with a slight correction to not overwrite files already downloaded):

wget -r -nc -np http://h4x0rz.bounceme.net/Urban%20Terror/maps/

Share this post


Link to post
Share on other sites

i just tried this and i have two problems

1) i want to put all the files in whatever direcotry i am currently in, i tested this on my desktop and it puts them in h4x0rZ.bounceme.net/Urban Terror/Maps. Maybe we could get rid of the recreate directories.

2) i want to only download .pk3 files because when it does this it downloads all the possible .html files created when broswing the directory. If you go to my website and click on "name" to sort by name you will have a file named index.html?C=N;O=D

Share this post


Link to post
Share on other sites

Thank you for helping me learn how to use wget i bet this will help later too. But now i realize i have two more questions:

1)How do i tell wget to not print out an output file? Or should i just do "rm wget-log"

2)How do i tell wget to stop after the window has been closed? is there any easy way of doing this?

 

Edit: Actually i have 3

3)How can i see if a domain is available? This is my attempt is it correct?

There are multiple mirrors, map_dl_mirror is the mirror

wget -d -r -np -nd -A .pk3 $map_dl_mirror || echo "WGET failed downloading."

Is there like a goto statement or maybe like some kinda loop i can put this in?

 

Here is my entire function so far:

#!/bin/bash

function dl_maps {
 cat << .end
 Select your mirror:
 ---------------------------
 [1]1337-h4x0rZ
 [2]
 [3]
 [7]

.end

 read dlmirror
 case "$dlmirror" in
 "1")
	  map_dl_mirror = "http://h4x0rz.bounceme.net/Urban%20Terror/maps/"
;;
 "2")
	  map_dl_mirror = ""
 "8")
 *)
	  echo "Invalid option"
	  dl_maps
 esac

 wget -d -r -np -nd -A .pk3 $map_dl_mirror || echo "WGET failed downloading."
}

Edit 2: Opps i miscounted there are only 7 mirrors i orginally had put the number 8. And mine's the best cause last week i had 186+ maps i have to check how many there are now. And i fixed the .end, i forogt it has to be all the way to the left.

Edited by Deo Favente

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...