From fc3874943d104cfa0f28e1bd8e8e903ac04c81c4 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 9 Jan 2018 19:39:49 +0000 Subject: [PATCH] lib/postgres/port.sql --- etc/profile.d/functions | 9 +++++++++ lib/postgres/port.sql | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 lib/postgres/port.sql diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 1f343d87..4e71e329 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -171,6 +171,15 @@ shell_functions() { (declare -f || typeset -f) 2> /dev/null | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}' } +shell_functions_csv() { + local i + for i in $(shell_functions); do + printf '%s\t' "$i" + type "$i" | tail -n +2 | tr -d "\n" | sed -e 's/\\/\\\\/g' -e 's/\t/\\t/g' + printf '\n' + done +} + shell_ssh() { local ssh_opt; case "$1" in -*) ssh_opt="$1"; [ "$#" -gt 0 ] && shift ;; esac local server; server="$1"; shift diff --git a/lib/postgres/port.sql b/lib/postgres/port.sql new file mode 100644 index 00000000..741e3d89 --- /dev/null +++ b/lib/postgres/port.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS port; +CREATE TABLE IF NOT EXISTS port ( + port INT, + proto VARCHAR(3), + name VARCHAR(100), + PRIMARY KEY (port,proto,name) +); + +BEGIN TRANSACTION; +DELETE FROM port; +COPY port FROM PROGRAM '\ +perl -ne "m,^(\w+)\s+(\d+)/(\w+)\s+#\s*(.*?)$, && print join(qq|\t|,map(/^\s*(.*?)\s*$/,\$2,\$3,\$1)).qq|\n|" /etc/services \ +' WITH (format 'text', NULL ''); +COMMIT; -- 2.47.3