diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-01-15 15:33:21 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-01-19 16:35:37 +0000 |
commit | 8e6d48d5ee351594fc92f1e680ba4a2219ed57ca (patch) | |
tree | a32bdde6047f357663883a995393a945e1dadff2 /bin | |
parent | 96dd07e7c1dab2c8f9250af435caad2c2818b5a2 (diff) |
Remove need for cron-wrapper with existing scripts
Call the necessary boilerplate in each script so you can call them
directly. Remove boilerplate from files that don't need it.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cron-wrapper | 6 | ||||
-rwxr-xr-x | bin/fetch-comments | 7 | ||||
-rwxr-xr-x | bin/fetch-comments-24hs | 10 | ||||
-rwxr-xr-x | bin/geocode | 9 | ||||
-rwxr-xr-x | bin/install-as-user | 8 | ||||
-rwxr-xr-x | bin/make_css_watch | 9 | ||||
-rwxr-xr-x | bin/open311-populate-service-list | 8 | ||||
-rwxr-xr-x | bin/open311-update-reports | 8 | ||||
-rwxr-xr-x | bin/problem-creation-graph | 11 | ||||
-rwxr-xr-x | bin/problems-filed-graph | 11 | ||||
-rwxr-xr-x | bin/run-tests | 6 | ||||
-rwxr-xr-x | bin/send-alerts | 7 | ||||
-rwxr-xr-x | bin/send-comments | 7 | ||||
-rwxr-xr-x | bin/send-questionnaires | 7 | ||||
-rwxr-xr-x | bin/send-reports | 7 | ||||
-rwxr-xr-x | bin/update-all-reports | 7 | ||||
-rwxr-xr-x | bin/update-schema | 16 | ||||
-rwxr-xr-x | bin/zurich/overdue-alert | 7 |
18 files changed, 128 insertions, 23 deletions
diff --git a/bin/cron-wrapper b/bin/cron-wrapper index 127fd8d8a..c75f0289b 100755 --- a/bin/cron-wrapper +++ b/bin/cron-wrapper @@ -1,8 +1,10 @@ #!/usr/bin/env perl BEGIN { # set all the paths to the perl code - use FindBin; - require "$FindBin::Bin/../setenv.pl"; + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; } exec { $ARGV[0] } @ARGV or die $!; diff --git a/bin/fetch-comments b/bin/fetch-comments index a276433e4..4eb9def14 100755 --- a/bin/fetch-comments +++ b/bin/fetch-comments @@ -8,6 +8,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use FixMyStreet::App; use CronFns; my ($verbose, $nomail) = CronFns::options(); diff --git a/bin/fetch-comments-24hs b/bin/fetch-comments-24hs index 602383d40..27853bcc1 100755 --- a/bin/fetch-comments-24hs +++ b/bin/fetch-comments-24hs @@ -7,9 +7,17 @@ use strict; use warnings; +require 5.8.0; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use DateTime; use DateTime::Format::W3CDTF; -require 5.8.0; use FixMyStreet::App; use CronFns; diff --git a/bin/geocode b/bin/geocode index 2b85ff572..2559f7a3c 100755 --- a/bin/geocode +++ b/bin/geocode @@ -6,8 +6,6 @@ geocode - commandline tool to test geocoders =head1 SYNOPSIS - $ eval `perl setenv.pl`, or call with bin/cron-wrapper - $ bin/geocode --geocoder=Bing --cobrand=bromley "Glebe Rd" # ... if your conf/general.yml supplies GEOCODER: @@ -24,6 +22,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use Data::Dumper; use Pod::Usage; use feature 'say'; diff --git a/bin/install-as-user b/bin/install-as-user index 33a74c140..0e1c151fb 100755 --- a/bin/install-as-user +++ b/bin/install-as-user @@ -127,15 +127,15 @@ then psql -U "$UNIX_USER" "$DB_NAME" < "$REPOSITORY"/db/alert_types.sql psql -U "$UNIX_USER" "$DB_NAME" < "$REPOSITORY"/db/generate_secret.sql else - bin/cron-wrapper update-schema --commit + bin/update-schema --commit fi echo $DONE_MSG # Generate po and mo files (these invocations taken from Kagee's script): echo "Creating locale .mo files" -bin/cron-wrapper bin/make_po FixMyStreet-EmptyHomes -bin/cron-wrapper bin/emptyhomes/make_welsh_po +bin/make_po FixMyStreet-EmptyHomes +bin/emptyhomes/make_welsh_po commonlib/bin/gettext-makemo FixMyStreet echo $DONE_MSG -bin/cron-wrapper update-all-reports +bin/update-all-reports diff --git a/bin/make_css_watch b/bin/make_css_watch index 63a27a35e..2ae287429 100755 --- a/bin/make_css_watch +++ b/bin/make_css_watch @@ -1,7 +1,16 @@ #!/usr/bin/env perl + use strict; use warnings; use feature 'say'; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use Cwd qw(abs_path); use File::ChangeNotify; use File::Find::Rule; diff --git a/bin/open311-populate-service-list b/bin/open311-populate-service-list index be1ace3b9..11f9005a5 100755 --- a/bin/open311-populate-service-list +++ b/bin/open311-populate-service-list @@ -2,6 +2,14 @@ use strict; use warnings; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use FixMyStreet::App; use Open311::PopulateServiceList; use Getopt::Long::Descriptive; diff --git a/bin/open311-update-reports b/bin/open311-update-reports index a964ba8c9..6a1c894d7 100755 --- a/bin/open311-update-reports +++ b/bin/open311-update-reports @@ -8,6 +8,14 @@ use strict; use warnings; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use Open311::GetUpdates; use FixMyStreet::App; diff --git a/bin/problem-creation-graph b/bin/problem-creation-graph index e1b6f2cc4..c3d10f934 100755 --- a/bin/problem-creation-graph +++ b/bin/problem-creation-graph @@ -10,13 +10,18 @@ use strict; use warnings; require 5.8.0; -use FindBin; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + chdir "$d/.."; + require "$d/../setenv.pl"; +} + use File::Temp qw(tempfile); use FixMyStreet::App; -chdir("$FindBin::Bin/../"); - my %config = ( gplot_output => "set terminal png font 'Vera.ttf' 9 size 1200,400", extension => '.png', diff --git a/bin/problems-filed-graph b/bin/problems-filed-graph index d3e132f8e..abfe0cf1a 100755 --- a/bin/problems-filed-graph +++ b/bin/problems-filed-graph @@ -10,13 +10,18 @@ use strict; use warnings; require 5.8.0; -use FindBin; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + chdir "$d/.."; + require "$d/../setenv.pl"; +} + use File::Temp qw(tempfile); use FixMyStreet::App; -chdir("$FindBin::Bin/../"); - my %config = ( gplot_output => "set terminal png font 'Vera.ttf' 9 size 1200,600", extension => '.png', diff --git a/bin/run-tests b/bin/run-tests index 42315e2f2..612a13628 100755 --- a/bin/run-tests +++ b/bin/run-tests @@ -2,8 +2,10 @@ use strict; use warnings; BEGIN { - use FindBin; - require "$FindBin::Bin/../setenv.pl"; + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; } use FixMyStreet::TestAppProve; diff --git a/bin/send-alerts b/bin/send-alerts index 00c5426bc..94f7d5509 100755 --- a/bin/send-alerts +++ b/bin/send-alerts @@ -10,6 +10,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use CGI; # XXX use CronFns; diff --git a/bin/send-comments b/bin/send-comments index 2192f674c..2d6b525b5 100755 --- a/bin/send-comments +++ b/bin/send-comments @@ -13,6 +13,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use Digest::MD5; use Encode; use CronFns; diff --git a/bin/send-questionnaires b/bin/send-questionnaires index 7ed3c87c2..93d58ed77 100755 --- a/bin/send-questionnaires +++ b/bin/send-questionnaires @@ -10,6 +10,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use CGI; # XXX Awkward kludge use Encode; use CronFns; diff --git a/bin/send-reports b/bin/send-reports index 16296dc5b..3c6f26cdb 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -10,6 +10,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use CGI; # XXX use CronFns; diff --git a/bin/update-all-reports b/bin/update-all-reports index f4d6113cb..f6cd34210 100755 --- a/bin/update-all-reports +++ b/bin/update-all-reports @@ -10,6 +10,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use FixMyStreet::App; use File::Path (); use File::Slurp; diff --git a/bin/update-schema b/bin/update-schema index af0da3601..ce193f29c 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -31,9 +31,13 @@ backup of your database before running. use strict; use warnings; -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../commonlib/perllib"; +my $bin_dir; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + $bin_dir = dirname(File::Spec->rel2abs($0)); + require "$bin_dir/../setenv.pl"; +} use mySociety::Config; use mySociety::DBHandle qw(dbh); @@ -41,7 +45,7 @@ use mySociety::MaPit; use Getopt::Long; use Pod::Usage; -mySociety::Config::set_file("$FindBin::Bin/../conf/general"); +mySociety::Config::set_file("$bin_dir/../conf/general"); my %args = ( Name => mySociety::Config::get('FMS_DB_NAME'), User => mySociety::Config::get('FMS_DB_USER'), @@ -115,7 +119,7 @@ if ($upgrade) { if ($version) { die "Not currently implemented"; } - for my $path (glob("$FindBin::Bin/../db/schema_*")) { + for my $path (glob("$bin_dir/../db/schema_*")) { my ($name) = $path =~ /schema_(.*)\.sql$/; next if $name le $current_version; next if $name =~ /$current_version-/; # For number only match @@ -146,7 +150,7 @@ if ($upgrade) { if ($downgrade) { my %downgrades; - for my $path (glob("$FindBin::Bin/../db/downgrade_*")) { + for my $path (glob("$bin_dir/../db/downgrade_*")) { my ($from, $to) = $path =~ /downgrade_(.*)---(.*)\.sql$/; next unless $from eq $current_version; $downgrades{$to} = $path; diff --git a/bin/zurich/overdue-alert b/bin/zurich/overdue-alert index fd9c26cb9..4a8fea830 100755 --- a/bin/zurich/overdue-alert +++ b/bin/zurich/overdue-alert @@ -10,6 +10,13 @@ use strict; use warnings; require 5.8.0; +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + use DateTime; use CronFns; use FixMyStreet::App; |