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