File: pgsql-nextsysid.get

package info (click to toggle)
wwwconfig-common 0.3.0
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 488 kB
  • sloc: sh: 952; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File:		pgsql-nextsysid.get
# Changes:
#	20010224 Ola Lundqvist <opal@debian.org>
#	20011022 Luca De Vitis <luca@debian.org>
#		Allowed reinclusion.
#	        Changed the piped commands with a single psql command using -A -q -t
#	20020116 Ola Lundqvist <opal@debian.org>
#		Documented the reinclusion.
#	20020126 Ola Lundqvist <opal@debian.org>
#		Fixed getting of next system id.
#	20020126 Ola Lundqvist <opal@debian.org>
#		Removed the reiclusion ability. It will recalculate now.
# Needs:	$pgsqlcmd  - the base sql command.
#		$systemdb  - the system db to use (optional)
#		psql
# Description:	Gets a password from 
# Sets:		$nextsysid = select max(usesysid) from pg_shadow; + 1
#		$status = {error, get}

nextsysid=
status=error
error=""

if $pgsqlcmd -d $systemdb -c "select max(usesysid) from pg_shadow;" > /dev/null 2>&1 ; then
    status=get
    tmpid=$($pgsqlcmd -d $systemdb -c "select max(usesysid) from pg_shadow;" | grep "^[[:space:]]*[0-9][0-9]*[[:space:]]*$")
    nextsysid=$((1 + $tmpid))
fi