]> mj.ucw.cz Git - gallery.git/blob - bin/gal-mj-upload
e7fce29f80017bdd143cfc7c6d5ec7e1433355d1
[gallery.git] / bin / gal-mj-upload
1 #!/usr/bin/perl
2 # This is a hack to upload a locally generated gallery to MJ's web.
3
4 use common::sense;
5
6 print "## Updating Git\n";
7 system "git", "pull";
8 die if $?;
9
10 print "## Ensuring that photos are generated\n";
11 system "gal", "gen";
12 die if $?;
13
14 use Cwd;
15 my $cwd = getcwd;
16 my ($root, $album) = $cwd =~ m{(.*)/photos/(.*)} or die "Cannot identify album from current directory, giving up.\n";
17 my $static = "$root/static/gallery/photo/$album";
18 -d $static or die "Cannot find generated photos in $static, giving up.\n";
19
20 print "## Uploading album $album\n";
21 system "rs", "$static/", "jw:www/static/gallery/photo/$album/";
22 die if $?;
23
24 print "## Calling editor on index files\n";
25 system 'vim', 'gallery.cf', "$root/photos/Makefile", "$root/photos/index.thtml";
26 die if $?;
27
28 print "## Committing to repository\n";
29 system 'git', 'add', 'gallery.cf', 'gallery.list'; die if #?;
30 system 'git', 'add', "$root/photos/Makefile", "$root/photos/index.thtml"; die if $?;
31 system 'git', 'commit'; die if $?;
32 system 'git', 'push'; die if $?;
33
34 print "## Pulling at the server\n";
35 system "ssh", "jw", "cd web && git pull && make";
36 die if $?;
37
38 print "## Regenerating cache at the server\n";
39 system "ssh", "jw", "cd web/photos/$album && ~/web/gal/gal cache";
40 die if $?;
41
42 print "Done.\n";