Last active
March 21, 2025 06:51
-
-
Save ManotLuijiu/ac3ecbc8981ed5f7fdd2319694731ed8 to your computer and use it in GitHub Desktop.
Systemd script for automate translation in Frappe/ERPNext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=ERPNext Thai Business Suite Translation Updater | |
After=network.target | |
[Service] | |
Type=oneshot | |
User=frappe | |
Group=frappe | |
WorkingDirectory=/home/frappe/moo-bench | |
ExecStart=/bin/bash -c '/usr/local/bin/bench update-po-files --app thai_business_suite && /usr/local/bin/bench compile-po-to-mo --app> | |
Restart=no | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Run ERPNext Thai Business Suite Translation Updater daily | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set up translation service files and enable them | |
# Default values | |
FRAPPE_USER="frappe" | |
BENCH_PATH="frappe-bench" | |
APP_NAME="erpnext" | |
# Check if running as root | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run as root or with sudo" | |
exit 1 | |
fi | |
# Get custom values if provided | |
read -p "Enter Frappe user name [$FRAPPE_USER]: " input_user | |
FRAPPE_USER=${input_user:-$FRAPPE_USER} | |
read -p "Enter bench directory name [$BENCH_PATH]: " input_bench | |
BENCH_PATH=${input_bench:-$BENCH_PATH} | |
read -p "Enter app name [$APP_NAME]: " input_app | |
APP_NAME=${input_app:-$APP_NAME} | |
FULL_PATH="/home/$FRAPPE_USER/$BENCH_PATH" | |
echo "Setting up with the following configuration:" | |
echo "Frappe User: $FRAPPE_USER" | |
echo "Bench Path: $FULL_PATH" | |
echo "App Name: $APP_NAME" | |
echo "" | |
# Step 1: Create the service file | |
cat > /etc/systemd/system/erpnext-translation.service << EOF | |
[Unit] | |
Description=Frappe/ERPNext $APP_NAME Translation Updater | |
After=network.target | |
[Service] | |
Type=oneshot | |
User=$FRAPPE_USER | |
Group=$FRAPPE_USER | |
WorkingDirectory=$FULL_PATH | |
ExecStart=/bin/bash -c '/usr/local/bin/bench update-po-files --app $APP_NAME && /usr/local/bin/bench compile-po-to-mo --app $APP_NAME' | |
Restart=no | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
echo "Service file created." | |
# Step 2: Create the timer file | |
cat > /etc/systemd/system/erpnext-translation.timer << 'EOF' | |
[Unit] | |
Description=Run Frappe/ERPNext $APP_NAME Translation Updater daily | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target | |
EOF | |
echo "Timer file created." | |
# Step 3 & 4: Enable and start timer and service | |
systemctl daemon-reload | |
systemctl enable erpnext-translation.timer | |
systemctl start erpnext-translation.timer | |
systemctl enable erpnext-translation.service | |
echo "Services enabled and started." | |
# Step 5: Verify status | |
echo "Checking service status..." | |
systemctl status erpnext-translation.service | |
echo "Checking timer status..." | |
systemctl status erpnext-translation.timer | |
echo "Setup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ERPNext Thai Translation Automation
This guide explains how to set up automatic translation updates for Thai language in ERPNext.
Automated Setup
Using Bash Script
Save the bash script to a file named
setup-translation-service.sh
in your home folder:curl -o ~/setup-translation-service.sh https://gist.githubusercontent.com/ManotLuijiu/ac3ecbc8981ed5f7fdd2319694731ed8/raw/65525574c323d7b83761d73e7c35e0d3ec422f64/setup-translation-service.sh
Make it executable:
chmod +x ~/setup-translation-service.sh
or 1 + 2
Run it with sudo:
Follow the prompts to customize the values if needed.
Manual Setup
Create 2 files:
Create the service file:
Add the following content:
Suppose your frappe folder is '/home/frappe/frappe-bench' and
your app name is thai_business_suite
Create the timer file:
Add the following content:
Enable and start the services:
Verifying the Status
Check the service status:
Example output:
This status indicates that the translation service is working correctly and has successfully updated the translation files.
What This Does
The service will: