-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4087c49
commit 125f9d8
Showing
15 changed files
with
277 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/vpn/conf/* | ||
*.conf | ||
!vpn/templates/*.conf | ||
.treehouses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
authUsage() { | ||
echo "Usage: $0 credential [command]" | ||
echo "Commands:" | ||
echo " login - Login azure as service-principal" | ||
exit 1 | ||
} | ||
|
||
function auth(){ | ||
|
||
# Check if at least one argument is provided | ||
if [ $# -eq 0 ]; then | ||
authUsage | ||
fi | ||
|
||
# Execute the appropriate command | ||
case "$1" in | ||
login) | ||
login | ||
;; | ||
*) | ||
echo "Error: Invalid command." | ||
authUsage | ||
;; | ||
esac | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source auth/login.sh | ||
source auth/driver.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function login(){ | ||
|
||
username=$(retrieveCred username) | ||
password=$(retrieveCred password) | ||
tenant=$(retrieveCred tenant_name) | ||
|
||
az login --service-principal --username $username --password $password --tenant $tenant | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Directory and file names | ||
DIR_NAME=".luftballon" | ||
FILE_NAME="credentials.txt" | ||
|
||
# Full path of the directory and the file | ||
DIR_PATH="$HOME/$DIR_NAME" | ||
FILE_PATH="$DIR_PATH/$FILE_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
credentialUsage() { | ||
echo "Usage: $0 credential [command]" | ||
echo "Commands:" | ||
echo " init - Initialize and store new credentials" | ||
echo " update - Update existing credentials" | ||
echo " show - Display current credentials" | ||
exit 1 | ||
} | ||
|
||
function credential(){ | ||
|
||
# Check if at least one argument is provided | ||
if [ $# -eq 0 ]; then | ||
credentialUsage | ||
fi | ||
|
||
# Execute the appropriate command | ||
case "$1" in | ||
init) | ||
initCreds | ||
;; | ||
update) | ||
updateCreds | ||
;; | ||
show) | ||
showCreds | ||
;; | ||
*) | ||
echo "Error: Invalid command." | ||
credentialUsage | ||
;; | ||
esac | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source credential/driver.sh | ||
source credential/setup.sh | ||
source credential/show.sh | ||
source credential/update.sh | ||
source credential/retrieve.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
retrieveCred() { | ||
local key=$1 | ||
local file=$FILE_PATH | ||
|
||
local value=$(grep "^$key=" "$file" | cut -d'=' -f2) | ||
|
||
if [ -z "$value" ]; then | ||
echo "" | ||
else | ||
echo $value | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
saveCreds() { | ||
read -p "Enter your username: " username | ||
read -sp "Enter your password: " password | ||
echo | ||
read -p "Enter your tenant name: " tenant_name | ||
|
||
# Storing credentials in the file | ||
echo "username=$username" > "$FILE_PATH" | ||
echo "password=$password" >> "$FILE_PATH" | ||
echo "tenant_name=$tenant_name" >> "$FILE_PATH" | ||
|
||
echo "Credentials stored successfully in $FILE_PATH." | ||
} | ||
|
||
checkDirFile() { | ||
if [ ! -d "$DIR_PATH" ]; then | ||
echo "Directory $DIR_PATH does not exist. Creating now." | ||
mkdir "$DIR_PATH" | ||
else | ||
echo "Directory $DIR_PATH already exists." | ||
fi | ||
|
||
if [ ! -f "$FILE_PATH" ]; then | ||
echo "Creating credentials file at $FILE_PATH." | ||
touch "$FILE_PATH" | ||
else | ||
echo "Credentials file already exists at $FILE_PATH." | ||
fi | ||
} | ||
|
||
initCreds() { | ||
checkDirFile | ||
saveCreds | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
showCreds() { | ||
if [ ! -f "$FILE_PATH" ]; then | ||
echo "Credentials file not found." | ||
exit 1 | ||
fi | ||
|
||
echo "Current credentials:" | ||
while IFS= read -r line; do | ||
if [[ $line == password=* ]]; then | ||
password=${line#password=} | ||
masked_password="${password:0:6}*****" | ||
echo "password=$masked_password" | ||
else | ||
echo "$line" | ||
fi | ||
done < "$FILE_PATH" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
updateCreds() { | ||
if [ ! -f "$FILE_PATH" ]; then | ||
echo "Credentials file not found. Please run the setup script first." | ||
exit 1 | ||
fi | ||
|
||
echo "Updating credentials..." | ||
|
||
# Update username | ||
read -p "Enter your new username (leave blank to keep current): " new_username | ||
if [ -n "$new_username" ]; then | ||
sed -i "s/^username=.*/username=$new_username/" "$FILE_PATH" | ||
fi | ||
|
||
# Update password | ||
read -sp "Enter your new password (leave blank to keep current): " new_password | ||
echo | ||
if [ -n "$new_password" ]; then | ||
sed -i "s/^password=.*/password=$new_password/" "$FILE_PATH" | ||
fi | ||
|
||
# Update tenant name | ||
read -p "Enter your new tenant name (leave blank to keep current): " new_tenant_name | ||
if [ -n "$new_tenant_name" ]; then | ||
sed -i "s/^tenant_name=.*/tenant_name=$new_tenant_name/" "$FILE_PATH" | ||
fi | ||
|
||
echo "Credentials updated successfully." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
source config.sh | ||
source load.sh | ||
|
||
rootUsage() { | ||
echo "Usage: $0 [command group] [command]" | ||
echo "Command groups:" | ||
echo " credential - Manage credentials (init, update, show)" | ||
echo " auth - Authentication management (login)" | ||
exit 1 | ||
} | ||
|
||
# Check if at least one argument is provided | ||
if [ $# -eq 0 ]; then | ||
rootUsage | ||
fi | ||
|
||
# Execute the appropriate command | ||
case "$1" in | ||
credential) | ||
credential "$2" | ||
;; | ||
auth) | ||
auth "$2" | ||
;; | ||
*) | ||
echo "Error: Invalid command." | ||
rootUsage | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
az group create --name luftballon --location eastus | ||
az vm create --resource-group luftballon --name luftballon --image Ubuntu2204 --admin-username hiroyuki --generate-ssh-keys --public-ip-sku Standard | ||
echo $(az vm show --show-details --resource-group luftballon --name luftballon --query publicIps --output tsv) | ||
az vm run-command invoke --resource-group luftballon --name luftballon --command-id RunShellScript --scripts "sudo apt-get update && sudo apt-get install -y nginx" | ||
az vm open-port --port 80 --resource-group luftballon --name luftballon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source credential/load.sh | ||
source auth/load.sh | ||
|