]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/host_ads.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 02:31:52 +0000 (02:31 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 02:31:52 +0000 (02:31 +0000)
etc/profile.d/functions
lib/postgres/continent.sql
lib/postgres/country.sql [new file with mode: 0644]
lib/postgres/grant.sql [new file with mode: 0644]
lib/postgres/host_ads.sql [new file with mode: 0644]
lib/postgres/timezone.sql [new file with mode: 0644]

index d7d42d71cf76fdb662487f7ff1dd6695edaf2289..1f343d87515d2239ad2b717fccaf8a993bb1b9d9 100644 (file)
@@ -168,10 +168,7 @@ shell_help_noarg() {
 }
 
 shell_functions() {
-# NB 15.02.16   set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"'
-       typeset -f | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}'
-# NB 07.02.17   typeset -f | perl -ne '/^([a-z][\w_-]+) \(\)\s*\{*$/ and print "$1\n"'
-       #set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1 "' | perl -pe 's/\s+$//'
+       (declare -f || typeset -f) 2> /dev/null | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}'
 }
 
 shell_ssh() {
index 67ad4b6a8cd577b55edc885a5fbf5638da5cde0b..14cceb10ed80e5a426cfcb4703c4932048ca8157 100644 (file)
@@ -4,9 +4,6 @@ CREATE TABLE IF NOT EXISTS continent (
   name varchar(200),
   geoid bigint UNIQUE
 );
-GRANT ALL ON TABLE continent TO www;
-GRANT ALL ON TABLE continent TO nico;
-GRANT ALL ON TABLE continent TO root;
 BEGIN TRANSACTION;
 DELETE FROM continent;
 COPY continent FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/readme.txt | awk "/^Continent codes/ {ok=1} ok==1 && /^$/{exit} ok==1 {print \$0}" | tail -n +2 | sed -e "s/ : /\t/" -e "s/[\t ]\+geonameId=/\t/"' WITH (format 'text', NULL ''); 
diff --git a/lib/postgres/country.sql b/lib/postgres/country.sql
new file mode 100644 (file)
index 0000000..b1c1fb3
--- /dev/null
@@ -0,0 +1,48 @@
+-- ISO
+-- ISO3
+-- ISO-Numeric
+-- fips
+-- Country
+-- Capital
+-- Area(in sq km)
+-- Population
+-- Continent
+-- tld
+-- CurrencyCode
+-- CurrencyName
+-- Phone
+-- Postal Code Format
+-- Postal Code Regex
+-- Languages
+-- geoid
+-- neighbours
+-- EquivalentFipsCode
+DROP TABLE IF EXISTS country;
+CREATE TABLE IF NOT EXISTS country (
+  id char(2) PRIMARY KEY,
+  -- iso char(3) UNIQUE,
+  iso3 char(3) UNIQUE,
+  isonum char(3) UNIQUE,
+  fips varchar(2),
+  name varchar(50),
+  capital varchar(30),
+  area_km varchar(9),
+  population bigint,
+  continent varchar(2),
+  tld varchar(10),
+  currency_code varchar(3),
+  currency_name varchar(20),
+  phone varchar(30),
+  zip_format varchar(60),
+  zip_regexp varchar(150),
+  languages varchar(100),
+  geoid bigint,
+  neighbours varchar(60),
+  eqfips varchar(2)
+);
+CREATE INDEX IF NOT EXISTS country_geoid_idx ON country (geoid);
+BEGIN TRANSACTION;
+DELETE FROM country;
+COPY country FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/countryInfo.txt | grep -v "^#" | sed "s/\\\\/\\\\\\\\/g"' WITH (format 'text', NULL ''); 
+COMMIT;
+
diff --git a/lib/postgres/grant.sql b/lib/postgres/grant.sql
new file mode 100644 (file)
index 0000000..b7a2bed
--- /dev/null
@@ -0,0 +1,3 @@
+GRANT ALL ON ALL TABLES IN SCHEMA public TO www;
+GRANT ALL ON ALL TABLES IN SCHEMA public TO root;
+GRANT ALL ON ALL TABLES IN SCHEMA public TO nico;
diff --git a/lib/postgres/host_ads.sql b/lib/postgres/host_ads.sql
new file mode 100644 (file)
index 0000000..55c5355
--- /dev/null
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS host_ads;
+CREATE TABLE IF NOT EXISTS host_ads (
+  host varchar(300) PRIMARY KEY
+);
+BEGIN TRANSACTION;
+DELETE FROM host_ads;
+COPY host_ads FROM PROGRAM 'curl -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml' WITH (format 'text', NULL ''); 
+COMMIT;
diff --git a/lib/postgres/timezone.sql b/lib/postgres/timezone.sql
new file mode 100644 (file)
index 0000000..694887b
--- /dev/null
@@ -0,0 +1,12 @@
+DROP TABLE IF EXISTS timezone;
+CREATE TABLE IF NOT EXISTS timezone (
+  id varchar(2),
+  name varchar(300),
+  gmt decimal(3,1),
+  dst decimal(3,1),
+  raw decimal(3,1)
+);
+BEGIN TRANSACTION;
+DELETE FROM timezone;
+COPY timezone FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/timeZones.txt | tail -n +2' WITH (format 'text', NULL ''); 
+COMMIT;