Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #73 (Video script updater) #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/lounge/www/admin/cgi-bin/updater
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
#
# ScreenInvader - A shared media experience. Instant and seamless.
# Copyright (C) 2012 Amir Hassan <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

. ./initcgi "text/html"

# Get root privileges
sudo -s <<EOF
EOF

baseURL="https://raw.github.com/Metalab/ScreenInvader/master/src/lounge/triggers/helpers/"

helpers=($(cat /lounge/www/cgi-bin/show | grep /]=\' | cut -d "'" -f2 | sort -u))

echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><meta http-equiv="Content-type" content="text/html;charset=UTF-8"></meta><title>ScreenInvader Update</title><html><head><link rel="stylesheet" type="text/css" href="../../_inc/css/lounge.css"><link rel="stylesheet" type="text/css" href="../_inc/css/admin.css"></link></head><body><form id="admin"><table><tbody><tr><td colspan="2" class="header">Update Results</td></tr>'

for i in "${helpers[@]}"
do
md5=($(md5sum /lounge/triggers/helpers/$i | cut -d " " -f1))
echo '<tr><td class="left">'$i'</td><td class="right">'
if wget --no-check-certificate -P "/lounge/triggers/helpers/tmp" $baseURL$i
then
if [ "$md5" == "$(md5sum /lounge/triggers/helpers/tmp/$i | cut -d ' ' -f1)" ]
then
echo 'Already up to date</td></tr>'
else
cp -f /lounge/triggers/helpers/tmp/$i /lounge/triggers/helpers/$i
echo 'Sucessfully updated</td></tr>'
fi
else
error="1"
echo 'ERROR</td></tr>'
fi
done

rm -r /lounge/triggers/helpers/tmp

if [ "$error" == "1" ]
then
echo '</tbody></table><br><span>Errors occured, try again later!</span></form></body>'
else
echo '</tbody></table><br><span>Update complete!</span></form></body>'
fi

3 changes: 3 additions & 0 deletions src/lounge/www/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
<hr/>
<input type="button" name="save" value="Save & Apply" id="save" />
</form>
<form id="admin">
<span class="button up" onclick="window.location.href='/admin/cgi-bin/updater'">Update Video Download Scripts</span>
</form>
</body>
</html>

Expand Down