1.0.53 • Published 1 year ago
mayohr-auto-punch v1.0.53
mayohr-auto-punch
Automatic punch in/out system for mayohr
Requirements
- Node.js 16+
Usage
Create a .env file
Create a .env file with your credentials:
# Download the .env.example file:
mkdir -p ~/.mayohr-auto-punch \
&& wget -O ~/.mayohr-auto-punch/.env \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/.env.example
# Update the .env file with your credentials:
vi ~/.mayohr-auto-punch/.envRun the script
npx --yes --quite mayohr-auto-punch@latestRun the script with Crontab
# Download the crontab config
mkdir -p ~/.mayohr-auto-punch/crontab && \
wget -O ~/.mayohr-auto-punch/crontab/mayohr-auto-punch.sh \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/examples/crontab/mayohr-auto-punch.sh && \
chmod +x ~/.mayohr-auto-punch/crontab/mayohr-auto-punch.sh && \
wget -O ~/.mayohr-auto-punch/crontab/mayohr \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/examples/crontab/mayohr
# Add to existing crontab (this will merge with your existing crontab entries)
crontab -l | cat - ~/.mayohr-auto-punch/crontab/mayohr | crontab -
# Verify the crontab settings
crontab -l
# To remove crontab, run crontab -eRun the script with PM2
# Install PM2
npm i -g pm2
# Download the pm2 configs:
wget -O ~/.mayohr-auto-punch/ecosystem.config.js \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/examples/pm2/ecosystem.config.js
# Start the script with PM2:
pm2 start ~/.mayohr-auto-punch/ecosystem.config.js \
&& pm2 stop mayohr-morning-punch mayohr-evening-punchRun the script with Docker
docker run --rm -it \
-v $HOME/.mayohr-auto-punch:/home/pptruser/.mayohr-auto-punch \
justintw/mayohr-auto-punch:latestRun the script with AWS Lambda
# Download the AWS template
mkdir -p ~/.mayohr-auto-punch/aws \
&& wget -O ~/.mayohr-auto-punch/aws/ecr-template.yaml \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/examples/aws/ecr-template.yaml \
&& wget -O ~/.mayohr-auto-punch/aws/lambda-template.yaml \
https://raw.githubusercontent.com/awesome-oa-tools/mayohr-auto-punch/main/examples/aws/lambda-template.yaml
source ~/.mayohr-auto-punch/.env
# Create SSM parameters for sensitive data
aws ssm put-parameter \
--no-cli-pager \
--region ap-northeast-1 \
--name "/mayohr-auto-punch/ms-password" \
--value "${MS_PASSWORD}" \
--type "SecureString" \
--overwrite
aws ssm put-parameter \
--no-cli-pager \
--region ap-northeast-1 \
--name "/mayohr-auto-punch/ms-totp-secret" \
--value "${MS_TOPT_SECRET}" \
--type "SecureString" \
--overwrite
aws ssm put-parameter \
--no-cli-pager \
--region ap-northeast-1 \
--name "/mayohr-auto-punch/telegram-bot-token" \
--value "${TELEGRAM_BOT_TOKEN}" \
--type "SecureString" \
--overwrite
# Create the ecr stack
aws cloudformation create-stack \
--no-cli-pager \
--region ap-northeast-1 \
--stack-name mayohr-auto-punch-ecr \
--template-body file://~/.mayohr-auto-punch/aws/ecr-template.yaml
# Get ECR URI
ECR_URI=$(aws cloudformation describe-stacks \
--no-cli-pager \
--region ap-northeast-1 \
--stack-name mayohr-auto-punch-ecr \
--query "Stacks[0].Outputs[?OutputKey=='RepositoryUri'].OutputValue" \
--output text)
# Login to ECR
aws ecr get-login-password \
--no-cli-pager \
--region ap-northeast-1 \
| docker login \
--username AWS \
--password-stdin \
${ECR_URI}
# Push the image to ECR
docker pull --platform linux/amd64 justintw/mayohr-auto-punch:latest \
&& docker tag justintw/mayohr-auto-punch:latest ${ECR_URI}:latest \
&& docker push ${ECR_URI}:latest
# Create the stack
aws cloudformation create-stack \
--no-cli-pager \
--region ap-northeast-1 \
--stack-name mayohr-auto-punch-lambda \
--template-body file://~/.mayohr-auto-punch/aws/lambda-template.yaml \
--parameters \
ParameterKey=ImageUri,ParameterValue=${ECR_URI}:latest \
ParameterKey=MsDomain,ParameterValue=${MS_DOMAIN} \
ParameterKey=MsUsername,ParameterValue=${MS_USERNAME} \
ParameterKey=TelegramEnabled,ParameterValue=${TELEGRAM_ENABLED} \
ParameterKey=TelegramChatId,ParameterValue=${TELEGRAM_CHAT_ID} \
--capabilities CAPABILITY_IAMTelegram Notification (Optional)
To enable Telegram notifications:
- Create a Telegram bot through @BotFather
- Create a Telegram Channel and add the bot to it as an admin
- Get Channel ID from https://api.telegram.org/bot<bot_token>/getUpdates
- Add the following to your
~/.mayohr-auto-punch/.envfile:
TELEGRAM_ENABLED="true"
TELEGRAM_BOT_TOKEN="your_bot_token"
TELEGRAM_CHAT_ID="your_chat_id"1.0.53
1 year ago
1.0.52
1 year ago
1.0.51
1 year ago
1.0.50
1 year ago
1.0.49
1 year ago
1.0.47
1 year ago
1.0.46
1 year ago
1.0.45
1 year ago
1.0.44
1 year ago
1.0.43
1 year ago
1.0.42
1 year ago
1.0.41
1 year ago
1.0.40
1 year ago
1.0.39
1 year ago
1.0.38
1 year ago
1.0.37
1 year ago
1.0.36
1 year ago
1.0.35
1 year ago
1.0.34
1 year ago
1.0.33
1 year ago
1.0.32
1 year ago
1.0.31
1 year ago
1.0.30
1 year ago
1.0.29
1 year ago
1.0.28
1 year ago
1.0.27
1 year ago
1.0.26
1 year ago
1.0.25
1 year ago
1.0.24
1 year ago
1.0.23
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.15
1 year ago
1.0.13
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago