From 2fbeec5a48b92dd5d8c666d24cbe0e75be0dfd39 Mon Sep 17 00:00:00 2001 From: ibraheemganayim Date: Sun, 13 Aug 2023 19:33:55 +0300 Subject: [PATCH 1/4] initial sol --- bash_project/.bash_profile | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/bash_project/.bash_profile b/bash_project/.bash_profile index 1bd30a1..75106a0 100755 --- a/bash_project/.bash_profile +++ b/bash_project/.bash_profile @@ -1 +1,50 @@ -# your solution here... \ No newline at end of file +#!/bin/bash + +# Greet the user +echo "Hello $USER" + +# Define environment variable +export COURSE_ID="DevOpsBootcampElevation" + +# Check .token file permissions +token_file="$HOME/.token" + +if [ -e "$token_file" ]; then + token_permissions=$(stat -c %a "$token_file") + + if [ "$token_permissions" != "600" ]; then + echo "Warning: $token_file file has too open permissions" + fi +else + echo "$token_file does not exist." +fi + +# Set umask +umask 0077 + +# Add directory to PATH +export PATH="$PATH:/home/$USER/usercommands" + +# Print current date in ISO 8601 format +echo "Date: $(date -u +"%Y-%m-%dT%H:%M:%S%z")" + +# Define command alias +alias ltxt='ls *.txt' + +# Create ~/tmp directory if it doesn't exist, and clean it if it does +tmp_dir=~/tmp +if [ ! -d "$tmp_dir" ]; then + mkdir "$tmp_dir" +else + rm -rf "$tmp_dir"/* +fi + +# Kill process bound to port 8080 if it exists +process_id=$(lsof -i :8080 -t) +if [ -n "$process_id" ]; then + kill "$process_id" +fi + +# Additional configs +summary = "*Script by Ibraheem G." +echo "$summary" \ No newline at end of file From 0fee6fee7b8de681d89c5c9f188f2b0cb5aa2a95 Mon Sep 17 00:00:00 2001 From: ibraheemganayim Date: Sun, 13 Aug 2023 19:37:10 +0300 Subject: [PATCH 2/4] fix warning regarding non-existing .token file --- bash_project/.bash_profile | 2 -- 1 file changed, 2 deletions(-) diff --git a/bash_project/.bash_profile b/bash_project/.bash_profile index 75106a0..401e6a8 100755 --- a/bash_project/.bash_profile +++ b/bash_project/.bash_profile @@ -15,8 +15,6 @@ if [ -e "$token_file" ]; then if [ "$token_permissions" != "600" ]; then echo "Warning: $token_file file has too open permissions" fi -else - echo "$token_file does not exist." fi # Set umask From fc8d05b2ae6669e540c40eed37ff88248ede7bbb Mon Sep 17 00:00:00 2001 From: ibraheemganayim Date: Sun, 13 Aug 2023 19:41:09 +0300 Subject: [PATCH 3/4] fix warning .token message --- bash_project/.bash_profile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bash_project/.bash_profile b/bash_project/.bash_profile index 401e6a8..c6a3d10 100755 --- a/bash_project/.bash_profile +++ b/bash_project/.bash_profile @@ -11,9 +11,8 @@ token_file="$HOME/.token" if [ -e "$token_file" ]; then token_permissions=$(stat -c %a "$token_file") - if [ "$token_permissions" != "600" ]; then - echo "Warning: $token_file file has too open permissions" + echo "Warning: .token file has too open permissions" fi fi From 91321e11af99892142903120eb1e33ee5c06e154 Mon Sep 17 00:00:00 2001 From: ibraheemganayim Date: Sun, 13 Aug 2023 19:43:14 +0300 Subject: [PATCH 4/4] fix umask --- bash_project/.bash_profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_project/.bash_profile b/bash_project/.bash_profile index c6a3d10..d73d7ea 100755 --- a/bash_project/.bash_profile +++ b/bash_project/.bash_profile @@ -17,7 +17,7 @@ if [ -e "$token_file" ]; then fi # Set umask -umask 0077 +umask 0006 # Add directory to PATH export PATH="$PATH:/home/$USER/usercommands"