Skip to content

Active User Script

Active User Script #1

# .github/workflows/update-active-user.yml
name: Active User Script
#when the active_user.sh is updated in the repo it will update the copy on the server
on:
push:
branches:
- main
paths:
- "Show active users/active-sessions.sh"
#allows manual triggering of the workflow
workflow_dispatch:
#replaces the old active_user.sh with the new one in the repo
jobs:
update_script:
runs-on: [self-hosted, linux]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Deploy active_user.sh
run: |
NEW_SCRIPT_PATH="${{ github.workspace }}/Show active users/active-sessions.sh"
PROFILE_SCRIPT_PATH="/etc/profile.d/active-sessions.sh"
if [ -f "$NEW_SCRIPT_PATH" ]; then
sudo /usr/bin/cp "$NEW_SCRIPT_PATH" "$PROFILE_SCRIPT_PATH"
sudo /usr/bin/chmod +x "$PROFILE_SCRIPT_PATH"
echo "active-sessions.sh updated successfully in $PROFILE_SCRIPT_PATH"
else
echo "Error: active_user.sh not found in repo folder!"
exit 1
fi
- name: Log update
run: echo "active-sessions.sh now runs active_user.sh at login."