Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FACT Demographic Statistics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FACT
FACT Data Services
FACT Demographic Statistics
Commits
a3261541
Commit
a3261541
authored
5 months ago
by
Riccardo Boero
Browse files
Options
Downloads
Patches
Plain Diff
Update gen_pop_data.sh
parent
27d81110
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gen_pop_data.sh
+22
-15
22 additions, 15 deletions
gen_pop_data.sh
with
22 additions
and
15 deletions
gen_pop_data.sh
+
22
−
15
View file @
a3261541
...
...
@@ -2,14 +2,14 @@
# Function to display help
function
show_help
()
{
echo
"Usage:
$0
<host> <user> <password>"
echo
"Usage:
$0
[
<host> <user> <password>
]
"
echo
""
echo
"This script sets up the database and loads the data."
echo
""
echo
"Arguments:"
echo
" host Database host"
echo
" user Database user"
echo
" password Database password"
echo
"Arguments
(optional if environment variables are set)
:"
echo
" host Database host
(or set DB_HOST)
"
echo
" user Database user
(or set DB_USER)
"
echo
" password Database password
(or set DB_PASSWORD)
"
}
# Check if help is requested
...
...
@@ -18,18 +18,25 @@ if [[ "$1" == "-h" || "$1" == "--help" ]]; then
exit
0
fi
# Check if all three parameters are provided
if
[[
$#
-ne
3
]]
;
then
echo
"Error: Missing arguments."
show_help
exit
1
# Check if all three arguments are provided or fallback to environment variables
if
[[
$#
-eq
3
]]
;
then
HOST
=
$1
USER
=
$2
PASSWORD
=
$3
else
# Check for environment variables
HOST
=
${
DB_HOST
}
USER
=
${
DB_USER
}
PASSWORD
=
${
DB_PASSWORD
}
# If either arguments or environment variables are missing, display help
if
[[
-z
"
$HOST
"
||
-z
"
$USER
"
||
-z
"
$PASSWORD
"
]]
;
then
echo
"Error: Missing arguments or environment variables."
show_help
exit
1
fi
fi
# Assign parameters to variables
HOST
=
$1
USER
=
$2
PASSWORD
=
$3
# create database
./inputs/setup_db.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment