Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/shelcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ShellCheck Lint

on:
push:
branches: [ "project" ]
pull_request:
branches: [ "project" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: '.'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hooks/task_commands.sh
hooks/commit_details.txt
6 changes: 6 additions & 0 deletions IIB2025041/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"FullName": "Yatharth Devendra Lanjewar",
"RollNumber": "IIB2025041",
"EmailAddress": "iib2025041@iiita.ac.in",
"RepositoryLink": "https://github.com/yatharth-xe/foss-geekhaven-task"
}
Binary file added IIB2025041/result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions hooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
msg=$(git log -1 --pretty=%B)
author=$(git log -1 --pretty=%an)
email=$(git log -1 --pretty=%ae)

echo "Commit Message: $msg" > hooks/commit_details.txt
echo "Author Name: $author" >> hooks/commit_details.txt
echo "Author Email: $email" >> hooks/commit_details.txt
59 changes: 59 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
if history 5 > /dev/null 2>&1; then
history 5 | sed 's/^[ ]*[0-9]*[ ]*//' > hooks/task_commands.sh
else
echo "git status" > hooks/task_commands.sh
echo "git add ." >> hooks/task_commands.sh
echo "git commit" >> hooks/task_commands.sh
fi
#!/usr/bin/env bash

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

echo -e "${BLUE}[*] Setting up git hooks and directories...${NC}"

mkdir -p hooks

cat << 'EOF' > .git/hooks/pre-commit
#!/usr/bin/env bash
if history 5 > /dev/null 2>&1; then
history 5 | sed 's/^[ ]*[0-9]*[ ]*//' > hooks/task_commands.sh
else
echo "git status" > hooks/task_commands.sh
echo "git add ." >> hooks/task_commands.sh
echo "git commit" >> hooks/task_commands.sh
fi
EOF

cat << 'EOF' > .git/hooks/post-commit
#!/usr/bin/env bash
msg=$(git log -1 --pretty=%B)
author=$(git log -1 --pretty=%an)
email=$(git log -1 --pretty=%ae)

echo "Commit Message: $msg" > hooks/commit_details.txt
echo "Author Name: $author" >> hooks/commit_details.txt
echo "Author Email: $email" >> hooks/commit_details.txt
EOF

chmod +x .git/hooks/pre-commit .git/hooks/post-commit

cp .git/hooks/pre-commit hooks/pre-commit
cp .git/hooks/post-commit hooks/post-commit

touch .gitignore
if ! grep -q "hooks/task_commands.sh" .gitignore; then
echo "hooks/task_commands.sh" >> .gitignore
echo -e "${YELLOW}[!] Added task_commands.sh to gitignore${NC}"
fi

if ! grep -q "hooks/commit_details.txt" .gitignore; then
echo "hooks/commit_details.txt" >> .gitignore
echo -e "${YELLOW}[!] Added commit_details.txt to gitignore${NC}"
fi

echo -e "${GREEN}[+] Done. Hooks are in place.${NC}"
70 changes: 70 additions & 0 deletions sysart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# sysart.sh — Print a fancy ASCII system-stats dashboard
# Task: foss-2026-task2 | Commit 2 of 2

set -euo pipefail

# ANSI colour codes
RED='\033[0;31m'
MAGENTA='\033[0;35m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
BOLD='\033[1m'
RESET='\033[0m'

print_logo() {
echo -e "${MAGENTA}${BOLD}"
cat <<'EOF'
███████╗ ██████╗ ███████╗███████╗ ████████╗ █████╗ ███████╗██╗ ██╗ ██████╗
██╔════╝██╔═══██╗██╔════╝██╔════╝ ██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ╚════██╗
█████╗ ██║ ██║███████╗███████╗ ██║ ███████║███████╗█████╔╝ █████╔╝
██╔══╝ ██║ ██║╚════██║╚════██║ ██║ ██╔══██║╚════██╗██╔═██╗ ██╔═══╝
██║ ╚██████╔╝███████║███████║ ██║ ██║ ██║███████╗██║ ██╗ ███████╗
╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝
System Dashboard — foss-2026-task2
EOF
echo -e "${RESET}"
}

separator() {
echo -e "${BLUE}────────────────────────────────────────────────────────────────────────────────────${RESET}"
}

cpu_usage() {
# Works on Linux; graceful fallback for others
if command -v top &>/dev/null; then
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' | xargs printf "%.1f%%"
else
echo "N/A"
fi
}

mem_usage() {
if command -v free &>/dev/null; then
free -h | awk '/^Mem:/ {printf "%s / %s (%.0f%%)", $3, $2, $3/$2*100}'
else
echo "N/A"
fi
}

disk_usage() {
df -h / | awk 'NR==2 {printf "%s used of %s (%s)", $3, $2, $5}'
}

print_dashboard() {
separator
echo ""
echo -e " ${RED}★${RESET} Task:"
echo -e " Cherry-pick the commit named ${CYAN}'Cherry pick this bitch'${RESET}"
echo -e " from ${GREEN}master${RESET} to ${GREEN}main${RESET}, then push the updated"
echo -e " ${GREEN}main${RESET} branch to the remote repository."
echo ""
}

main() {
print_logo
print_dashboard
}

main "$@"
51 changes: 51 additions & 0 deletions task3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

echo -e "${BLUE}[*] Setting up git hooks and directories...${NC}"

mkdir -p hooks

cat << 'EOF' > .git/hooks/pre-commit
#!/usr/bin/env bash
if history 5 > /dev/null 2>&1; then
history 5 | sed 's/^[ ]*[0-9]*[ ]*//' > hooks/task_commands.sh
else
echo "git status" > hooks/task_commands.sh
echo "git add ." >> hooks/task_commands.sh
echo "git commit" >> hooks/task_commands.sh
fi
EOF

cat << 'EOF' > .git/hooks/post-commit
#!/usr/bin/env bash
msg=$(git log -1 --pretty=%B)
author=$(git log -1 --pretty=%an)
email=$(git log -1 --pretty=%ae)

echo "Commit Message: $msg" > hooks/commit_details.txt
echo "Author Name: $author" >> hooks/commit_details.txt
echo "Author Email: $email" >> hooks/commit_details.txt
EOF

chmod +x .git/hooks/pre-commit .git/hooks/post-commit

cp .git/hooks/pre-commit hooks/pre-commit
cp .git/hooks/post-commit hooks/post-commit

touch .gitignore
if ! grep -q "hooks/task_commands.sh" .gitignore; then
echo "hooks/task_commands.sh" >> .gitignore
echo -e "${YELLOW}[!] Added task_commands.sh to gitignore${NC}"
fi

if ! grep -q "hooks/commit_details.txt" .gitignore; then
echo "hooks/commit_details.txt" >> .gitignore
echo -e "${YELLOW}[!] Added commit_details.txt to gitignore${NC}"
fi

echo -e "${GREEN}[+] Done. Hooks are in place.${NC}"
37 changes: 37 additions & 0 deletions test_task3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

BLUE='\033[0;34m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

echo -e "${BLUE}[INFO] Verifying Task 3 components...${NC}"

ERRORS=0

if [ -d "hooks" ]; then
echo -e "${GREEN}[SUCCESS] 'hooks' directory found.${NC}"
else
echo -e "${RED}[ERROR] 'hooks' directory missing.${NC}"
ERRORS=$((ERRORS + 1))
fi

if [ -f "hooks/pre-commit" ] && [ -f "hooks/post-commit" ]; then
echo -e "${GREEN}[SUCCESS] Hook scripts are present in 'hooks/'.${NC}"
else
echo -e "${RED}[ERROR] Hook scripts missing in 'hooks/'.${NC}"
ERRORS=$((ERRORS + 1))
fi

if [ -f "hooks/task_commands.sh" ] && [ -f "hooks/commit_details.txt" ]; then
echo -e "${GREEN}[SUCCESS] Generated log files are present inside 'hooks/'.${NC}"
else
echo -e "${YELLOW}[WARNING] Log files not found inside 'hooks/'.${NC}"
fi

if [ $ERRORS -eq 0 ]; then
echo -e "${GREEN}=== Task 3 Verification Passed Successfully! ===${NC}"
else
echo -e "${RED}=== Verification completed with $ERRORS error(s). ===${NC}"
fi