From 4f886b2cbbc86353c81364710f187cc07aec0305 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 17 Aug 2008 15:20:12 +0200 Subject: add some sanity checks --- bin/addproject | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'bin/addproject') diff --git a/bin/addproject b/bin/addproject index 4a038dd..660a245 100755 --- a/bin/addproject +++ b/bin/addproject @@ -1,25 +1,38 @@ #!/bin/bash +dbquery() { + mysql -s -s -e "$@" trac +} + # main function main() { echo - + # project_name may not be an empty string and must be >= 3 characters while [[ ${#project_name} -lt 3 ]] do eask_str "a project name (min 3 chars)" project_name=${REPLY} done - + + if [[ -n $(dbquery "SELECT id FROM project WHERE project_name = '${project_name}'") ]] + then + eerror "Project ${project_name} already exists." + fi + # who requests the project ? - while [[ -z ${user_email} ]] + while [[ -z ${user_name} ]] do - eask_str "email address (*.fu-berlin.de) of applicant" - user_email=${REPLY} - don (*.fu-berlin.de) of applicant" - user_email=${REPLY} + eask_str "username of applicant" + user_name=${REPLY} done + user_email=$(dbquery "SELECT email FROM user WHERE login = '${user_name}'") + if [[ -z ${user_email} ]] + then + eerror "Username ${user_name} does not exist." + fi + einfo einfo "$(color yellow)public project:$(color) read access for everyone with a spline-dev account." \ "write access only for project members. this is the default." -- cgit v1.2.3