diff --git a/.github/workflows/shelcheck.yml b/.github/workflows/shelcheck.yml new file mode 100644 index 0000000..03f95bc --- /dev/null +++ b/.github/workflows/shelcheck.yml @@ -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: '.' \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..376f892 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +hooks/task_commands.sh +hooks/commit_details.txt diff --git a/IIB2025041/info.json b/IIB2025041/info.json new file mode 100644 index 0000000..b8048ae --- /dev/null +++ b/IIB2025041/info.json @@ -0,0 +1,6 @@ +{ + "FullName": "Yatharth Devendra Lanjewar", + "RollNumber": "IIB2025041", + "EmailAddress": "iib2025041@iiita.ac.in", + "RepositoryLink": "https://github.com/yatharth-xe/foss-geekhaven-task" +} diff --git a/IIB2025041/result.png b/IIB2025041/result.png new file mode 100644 index 0000000..c4535b2 Binary files /dev/null and b/IIB2025041/result.png differ diff --git a/hooks/post-commit b/hooks/post-commit new file mode 100755 index 0000000..c35d5bc --- /dev/null +++ b/hooks/post-commit @@ -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 diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..8eceb49 --- /dev/null +++ b/hooks/pre-commit @@ -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}" \ No newline at end of file diff --git a/sysart.sh b/sysart.sh new file mode 100755 index 0000000..36cdbdf --- /dev/null +++ b/sysart.sh @@ -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 "$@" diff --git a/task3.sh b/task3.sh new file mode 100644 index 0000000..e2e11a1 --- /dev/null +++ b/task3.sh @@ -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}" \ No newline at end of file diff --git a/test_task3.sh b/test_task3.sh new file mode 100755 index 0000000..4e0ca3b --- /dev/null +++ b/test_task3.sh @@ -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