From: Nicolas Boisselier Date: Sat, 6 Jan 2018 02:31:52 +0000 (+0000) Subject: lib/postgres/host_ads.sql X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=fe14d357a1b8cc8cdfebf31d067b555eb6a78fab;p=nb.git lib/postgres/host_ads.sql --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index d7d42d71..1f343d87 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -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() { diff --git a/lib/postgres/continent.sql b/lib/postgres/continent.sql index 67ad4b6a..14cceb10 100644 --- a/lib/postgres/continent.sql +++ b/lib/postgres/continent.sql @@ -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 index 00000000..b1c1fb3e --- /dev/null +++ b/lib/postgres/country.sql @@ -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 index 00000000..b7a2bed0 --- /dev/null +++ b/lib/postgres/grant.sql @@ -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 index 00000000..55c53551 --- /dev/null +++ b/lib/postgres/host_ads.sql @@ -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 index 00000000..694887b0 --- /dev/null +++ b/lib/postgres/timezone.sql @@ -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;