# HG changeset patch # User HIROSE Yuuji # Date 1554554093 -32400 # Node ID 1f7d6999ed4c23a2728418ed6f21b7c5c0460052 # Parent bb34c7fbf1ad4be4cd01e4979d036a2068a8c807 Rename group-add script diff -r bb34c7fbf1ad -r 1f7d6999ed4c scripts/add-group-csv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/add-group-csv.sh Sat Apr 06 21:34:53 2019 +0900 @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ -z "$1" ]; then + cat<<-EOF >&2 + Usage: $0 CSVfile + $0 -a CSVfile # for al + Csv file should be the form of: + GroupName,UserName(email) + EOF + exit 1 +fi +cd `dirname $0`/.. +if ! . ./s4-funcs.sh; then + echo "Cannot find s4-funcs.sh, which should be located in $mydir/.." + exit 1 +fi + +target=$(cd `dirname "$1"`; pwd)/`basename $1` + +query<<-EOF + .mode csv + CREATE TEMPORARY TABLE _gusers(gname, user, admin); + .import $target _gusers + REPLACE INTO grp SELECT * FROM _gusers; + REPLACE INTO grp_adm SELECT * FROM _gusers WHERE admin LIKE 'admin'; +EOF diff -r bb34c7fbf1ad -r 1f7d6999ed4c scripts/group-add.sh --- a/scripts/group-add.sh Sat Apr 06 21:33:17 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#!/bin/sh - -if [ -z "$1" ]; then - cat<<-EOF >&2 - Usage: $0 CSVfile - $0 -a CSVfile # for al - Csv file should be the form of: - GroupName,UserName(email) - EOF - exit 1 -fi - -target=$(cd `dirname "$1"`; pwd)/`basename $1` - -query<<-EOF - .mode csv - CREATE TEMPORARY TABLE _gusers(gname, user, admin); - .import $target _gusers - REPLACE INTO grp SELECT * FROM _gusers; - REPLACE INTO grp_adm SELECT * FROM _gusers WHERE admin LIKE 'admin'; -EOF