separate out the process of installing a game pack into a .sh file, for later "adding...
[xonotic/netradiant.git] / download-gamepacks.sh
1 #!/bin/sh
2
3 # Usage:
4 #   sh download-gamepack.sh
5 #   LICENSEFILTER=GPL BATCH=1 sh download-gamepack.sh
6
7 set -e
8
9 pack()
10 {
11         pack=$1; shift
12         license=$1; shift
13         sourcetype=$1; shift
14         source=$1; shift
15
16         if [ -d "games/$pack" ]; then
17                 echo "Updating $pack..."
18                 case "$sourcetype" in
19                         svn)
20                                 svn update "games/$pack" "$@"
21                                 ;;
22                         zip1)
23                                 rm -rf zipdownload
24                                 mkdir zipdownload
25                                 cd zipdownload
26                                 wget "$source" "$@"
27                                 unzip *
28                                 cd ..
29                                 rm -rf "games/$pack"
30                                 mkdir "games/$pack"
31                                 mv zipdownload/*/* "games/$pack/"
32                                 rm -rf zipdownload
33                                 ;;
34                 esac
35                 return
36         fi
37
38         echo
39         echo "Available pack: $pack"
40         echo "  License: $license"
41         echo "  Download via $sourcetype from $source"
42         echo
43         case " $PACKFILTER " in
44                 "  ")
45                         ;;
46                 *" $pack "*)
47                         ;;
48                 *)
49                         echo "Pack $pack rejected because it is not in PACKFILTER."
50                         return
51                         ;;
52         esac
53         case " $LICENSEFILTER " in
54                 "  ")
55                         ;;
56                 *" $license "*)
57                         ;;
58                 *)
59                         echo "Pack $pack rejected because its license is not in LICENSEFILTER."
60                         return
61                         ;;
62         esac
63         case "$BATCH" in
64                 '')
65                         while :; do
66                                 echo "Download this pack? (y/n)"
67                                 read -r P
68                                 case "$P" in
69                                         y*)
70                                                 break
71                                                 ;;
72                                         n*)
73                                                 return
74                                                 ;;
75                                 esac
76                         done
77                         ;;
78                 *)
79                         ;;
80         esac
81         
82         echo "Downloading $pack..."
83         case "$sourcetype" in
84                 svn)
85                         svn checkout "$source" "games/$pack" "$@"
86                         ;;
87                 zip1)
88                         rm -rf zipdownload
89                         mkdir zipdownload
90                         cd zipdownload
91                         wget "$source" "$@"
92                         unzip *
93                         cd ..
94                         mkdir "games/$pack"
95                         mv zipdownload/*/* "games/$pack/"
96                         rm -rf zipdownload
97                         ;;
98         esac
99 }
100
101 mkdir -p games
102 pack DarkPlacesPack  GPL         svn  https://zerowing.idsoftware.com/svn/radiant.gamepacks/DarkPlacesPack/branches/1.5/
103 pack NexuizPack      GPL         svn  svn://svn.icculus.org/nexuiz/trunk/misc/netradiant-NexuizPack
104 pack OpenArenaPack   unknown     zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
105 pack Q3Pack          proprietary svn  https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ -r29
106 pack Quake2Pack      proprietary zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
107 pack Quake2WorldPack GPL         svn  svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
108 pack QuakePack       proprietary zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
109 pack TremulousPack   proprietary zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
110 pack UFOAIPack       proprietary svn  https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/
111 pack WarsowPack      GPL         svn  http://opensvn.csie.org/warsowgamepack/netradiant/games/WarsowPack/