-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·42 lines (36 loc) · 1.16 KB
/
run.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
function helpFunction() {
echo ""
echo "Usage: $0 -n 'Blob Fullname' -e [email protected] -c \"Blob's Macbook\""
echo -e "\t-n Git user name"
echo -e "\t-e Git user email"
echo -e "\t-c Computer name"
exit 1
}
while getopts "n:e:c:" opt; do
case "$opt" in
n ) gitUserName="$OPTARG" ;;
e ) gitUserEmail="$OPTARG" ;;
c ) computerName="$OPTARG" ;;
? ) helpFunction ;;
esac
done
if [ -z "$gitUserName" ] || [ -z "$gitUserEmail" ] || [ -z "$computerName" ]; then
echo "Some or all of the parameters are empty";
helpFunction
fi
computerName="${computerName// /-}"
computerName="${computerName//\'}"
computerName="${computerName//.}"
computerName="${computerName//,}"
echo "Git user name: ${gitUserName}"
echo "Git user email: ${gitUserEmail}"
echo "Computer name: ${computerName}"
echo "Local host name: ${computerName}"
echo "Looks good? [y/n]"
read -r response
if [[ $response =~ ^([yY])$ ]]; then
ansible-playbook --connection=local setup.yml --extra-vars "git_user_name='${gitUserName}' git_user_email='${gitUserEmail}' computer_name='${computerName}' local_host_name='${computerName}'"
else
echo "Ok, bye"
fi