-
Notifications
You must be signed in to change notification settings - Fork 14
/
upload.rb
executable file
·133 lines (115 loc) · 3.62 KB
/
upload.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/ruby
def sh(c)
outl = []
IO.popen(c) do |f|
while not f.eof?
tval = f.gets
puts tval
outl.push(tval)
end
end
return outl.join("")
end
def cat(c)
outl = []
f = File.open(c, "r")
f.each do |line|
outl.push(line)
end
f.close
return outl.join("")
end
def writef(fn, c)
File.open(fn, "w") do |f|
f.puts(c)
end
end
def readf(fn)
return File.open(fn, 'r') do |f|
f.read()
end
end
ver = nil
begin
ver = (cat 'version.txt').split('\n')[0].to_i
rescue
puts "no version.txt"
exit
end
$ver = ver
def redirouthtm_url(turl)
return <<eos
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="REFRESH" content="0; url=#{turl}">
<link rel="canonical" href="#{turl}" />
<title>Redirecting</title>
</head>
<body>
<script>
window.location.replace("#{turl}");
</script>
</body>
</html>
eos
end
def rediroutphp_url(turl)
return <<eos
<?php
header( 'Location: #{turl}' ) ;
?>
eos
end
def sfurl(outstr)
return "http://downloads.sourceforge.net/unetbootin/#{outstr}"
end
def lpurl(outstr)
return "http://launchpad.net/unetbootin/trunk/#{$ver}/+download/#{outstr}"
end
def ghurl(outstr)
return "https://github.com/unetbootin/unetbootin/releases/download/#{$ver}/#{outstr}"
end
$tourl = lambda {|x| ghurl(x) }
download_site = 'gh' # sf or lp or gh
if download_site == 'lp'
$tourl = lambda {|x| lpurl(x) }
end
if download_site == 'sf'
$tourl = lambda {|x| sfurl(x) }
end
def redirouthtm(outstr)
return redirouthtm_url($tourl.call(outstr))
end
def rediroutphp(outstr)
return rediroutphp_url($tourl.call(outstr))
end
writef('unetbootin-linux-latest/index.html' , redirouthtm("unetbootin-linux-#{ver}.bin"))
writef('unetbootin-linux-latest/index.php' , rediroutphp("unetbootin-linux-#{ver}.bin"))
writef('unetbootin-linux64-latest/index.html' , redirouthtm("unetbootin-linux64-#{ver}.bin"))
writef('unetbootin-linux64-latest/index.php' , rediroutphp("unetbootin-linux64-#{ver}.bin"))
writef('unetbootin-windows-latest.exe/index.html' , redirouthtm("unetbootin-windows-#{ver}.exe"))
writef('unetbootin-windows-latest.exe/index.php' , rediroutphp("unetbootin-windows-#{ver}.exe"))
writef('unetbootin-mac-latest.zip/index.html' , redirouthtm("unetbootin-mac-#{ver}.zip"))
writef('unetbootin-mac-latest.zip/index.php' , rediroutphp("unetbootin-mac-#{ver}.zip"))
writef('unetbootin-mac-latest.dmg/index.html' , redirouthtm("unetbootin-mac-#{ver}.dmg"))
writef('unetbootin-mac-latest.dmg/index.php' , rediroutphp("unetbootin-mac-#{ver}.dmg"))
writef('unetbootin-source-latest.zip/index.html' , redirouthtm("unetbootin-source-#{ver}.zip"))
writef('unetbootin-source-latest.zip/index.php' , rediroutphp("unetbootin-source-#{ver}.zip"))
writef('unetbootin-source-latest.tar.gz/index.html', redirouthtm("unetbootin-source-#{ver}.tar.gz"))
writef('unetbootin-source-latest.tar.gz/index.php' , rediroutphp("unetbootin-source-#{ver}.tar.gz"))
def sub_redirects(infile, outfile)
contents = readf(infile)
for x in ['unetbootin-linux-latest.bin', 'unetbootin-linux64-latest.bin', 'unetbootin-windows-latest.exe', 'unetbootin-mac-latest.dmg', 'unetbootin-mac-latest.zip', 'unetbootin-source-latest.zip', 'unetbootin-source-latest.tar.gz']
url = $tourl.call(x.sub('latest', $ver.to_s()))
contents = contents.gsub(x, url)
end
writef(outfile, contents)
end
sub_redirects('index_template.html', 'index.html')
sub_redirects('linux_download_template.html', 'linux_download.html')
if ARGV.include?('upload') or ARGV.include?('push')
sh 'git commit -a -m "updated website"'
sh 'git push origin master'
sh 'rsync -avP --exclude .git -e ssh . gezakovacs,[email protected]:/home/groups/u/un/unetbootin/htdocs'
end