summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/getpkg
diff options
context:
space:
mode:
Diffstat (limited to 'urunlevel/my_linux/Trinux/getpkg')
-rwxr-xr-xurunlevel/my_linux/Trinux/getpkg171
1 files changed, 171 insertions, 0 deletions
diff --git a/urunlevel/my_linux/Trinux/getpkg b/urunlevel/my_linux/Trinux/getpkg
new file mode 100755
index 0000000..adeab02
--- /dev/null
+++ b/urunlevel/my_linux/Trinux/getpkg
@@ -0,0 +1,171 @@
1#!/bin/sh
2#
3# getpkg - retrieves a single package from package server
4#
5# Author: Matthew D. Franz <mdfranz@io.com>
6#
7# $1 - name of package
8# $2 - URL of server
9#
10############################################################################
11
12[ -d /var/pkg/contents ] || mkdir -p /var/pkg/contents
13
14# if in current directory, call pkgadd
15
16if [ -f "$1" ]
17then
18 pkgadd $i
19else
20 if [ -f /etc/tux/config/localpkg ]
21 then
22 print "Using local package repository"
23 if [ -f /etc/proc/fixed ]
24 then
25 print "Found /etc/proc/fixed"
26 fi
27 fi
28fi
29
30
31if [ -f /etc/tux/config/proxy ]
32then
33 SNARF_PROXY=`cat /etc/tux/config/proxy`
34 export SNARF_PROXY
35fi
36
37mkdir /etc/init.d/running 2> /dev/null
38
39if [ "$1" = "list" ]
40then
41 pkglist
42 exit
43fi
44
45if [ "$1" = "all" ]
46 then
47 echo "Downloading all packages..."
48
49 if [ ! -f /etc/tux/config/eth0 ]
50 then
51 echo "Network was not configured"
52 if dmesg | grep eth0 > /dev/null
53 then
54 echo -n "Attempting DHCP on eth0: "
55 if dhcpcd > /dev/null 2> /dev/null
56 then
57 echo "Successful"
58 else
59 echo "Failed"
60 exit
61 fi
62 else
63 echo "No ethernet interfaces were found"
64 exit
65 fi
66 fi
67
68 if [ -f /etc/tux/config/pkglist ]
69 then
70 pkglist=`cat /etc/tux/config/pkglist`
71 for i in $pkglist
72 do
73 getpkg $i
74 done
75 else
76 echo "No package list found, retrieving a minimal set"
77 getpkg baselib
78 getpkg term
79 getpkg vi
80 getpkg tcpdump
81 fi
82
83 exit
84fi
85
86if [ "$1" = "" ]
87then
88 echo; echo "You did not specify a package or server!"; echo
89 echo "getpkg all will load all the packages from /etc/tux/config/pkglist"
90 getpkg all
91else
92 if [ "$2" = "" ]
93 then
94 if [ "$URL" = "" ]
95 then
96 if [ -f /etc/tux/config/server ]
97 then
98 blah=1
99 else
100 echo -n "Enter URL for package retrieval: "
101 read URL
102 if [ "$URL" != "" ]
103 then
104 echo "Using $URL as your package server from now on..."
105 echo "$URL" > /etc/tux/config/server
106 fi
107 fi
108 fi
109 else
110 URL=$2
111 fi
112
113 if echo $1 | grep tgz > /dev/null
114 then
115 FILE=$1
116 else
117 FILE=$1.tgz
118 fi
119
120 cd /
121
122 PREFIX=`basename $FILE ".tgz"`
123
124 #echo $PREFIX
125
126 MODPKGNAME=`echo ${1} | cut -d'/' -f2`
127
128
129 if echo $MODPKGNAME | grep tgz > /dev/null
130 then
131 MODPKGNAME=`basename $MODPKGNAME ".tgz"`
132 fi
133
134 # Loop through servers listed in
135
136 for URL in `cat /etc/tux/config/server`
137 do
138 if snarf $URL - > /dev/null 2> /dev/null
139 then
140 echo "Retrieving ${URL}${FILE}"
141 output=`snarf ${URL}/${FILE} - | gunzip -c | tar xvf -`
142 fi
143
144 echo $output > /var/pkg/contents/$PREFIX
145
146 if [ -f /etc/init.d/${PREFIX} ]
147 then
148 chmod a+x /etc/init.d/${PREFIX} 2> /dev/null
149 echo; echo "Initializing ${PREFIX}"
150 /etc/init.d/${PREFIX} 2> /dev/null
151 fi
152
153
154 if [ "$MODPKGNAME" ]
155 then
156 chmod a+x /etc/init.m/${MODPKGNAME} 2> /dev/null
157 if [ -x /etc/init.m/$MODPKGNAME ]
158 then
159 /etc/init.m/$MODPKGNAME
160 echo "Initializing $1 modules"
161 fi
162 fi
163
164
165 break
166 done
167
168 [ $? -eq 0 ] || exit 1
169
170fi
171