-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-cron.sh
72 lines (56 loc) · 3.54 KB
/
setup-cron.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
ENV="env"
ENV_NTLS_STAGING="ntls-staging"
ENV_NTLS_DEMO="ntls-demo"
ENV_PALAU_STAGING="palau-staging"
ENV_PALAU_DEMO="palau-demo"
ENV_BHUTAN_STAGING="bhutan-staging"
ENV_BHUTAN_DEMO="bhutan-demo"
# Path to the script
TS_SCRIPT_PATH_NTLS_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_ntls_staging.ts"
JS_SCRIPT_PATH_NTLS_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_ntls_staging.js"
TS_SCRIPT_PATH_NTLS_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_ntls_demo.ts"
JS_SCRIPT_PATH_NTLS_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_ntls_demo.js"
TS_SCRIPT_PATH_PALAU_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_palau_staging.ts"
JS_SCRIPT_PATH_PALAU_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_palau_staging.js"
TS_SCRIPT_PATH_PALAU_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_palau_demo.ts"
JS_SCRIPT_PATH_PALAU_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_palau_demo.js"
TS_SCRIPT_PATH_BHUTAN_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_bhutan_staging.ts"
JS_SCRIPT_PATH_BHUTAN_STAGING="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_bhutan_staging.js"
TS_SCRIPT_PATH_BHUTAN_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_bhutan_demo.ts"
JS_SCRIPT_PATH_BHUTAN_DEMO="$HOME/nautilus-wallet-recurring-payment/recurring_payment_script_bhutan_demo.js"
# Create the logs directory if it doesn't exist
mkdir -p logs
cd logs
mkdir -p $ENV_NTLS_STAGING
mkdir -p $ENV_NTLS_DEMO
mkdir -p $ENV_PALAU_STAGING
mkdir -p $ENV_PALAU_DEMO
mkdir -p $ENV_BHUTAN_STAGING
mkdir -p $ENV_BHUTAN_DEMO
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
# Install dependencies
npm install
# Transpile TypeScript to JavaScript
npx tsc "$TS_SCRIPT_PATH_NTLS_STAGING"
npx tsc "$TS_SCRIPT_PATH_NTLS_DEMO"
npx tsc "$TS_SCRIPT_PATH_PALAU_STAGING"
npx tsc "$TS_SCRIPT_PATH_PALAU_DEMO"
npx tsc "$TS_SCRIPT_PATH_BHUTAN_STAGING"
npx tsc "$TS_SCRIPT_PATH_BHUTAN_DEMO"
# Create a temporary file for the consolidated cron job
CRON_JOB_TEMP_FILE="/tmp/cronjob_temp"
# Add all cron jobs to the temporary file
echo "0 7 * * * node $JS_SCRIPT_PATH_NTLS_STAGING >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_NTLS_STAGING/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" > "$CRON_JOB_TEMP_FILE"
echo "0 7 * * * node $JS_SCRIPT_PATH_NTLS_DEMO >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_NTLS_DEMO/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" >> "$CRON_JOB_TEMP_FILE"
echo "0 7 * * * node $JS_SCRIPT_PATH_PALAU_STAGING >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_PALAU_STAGING/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" >> "$CRON_JOB_TEMP_FILE"
echo "0 7 * * * node $JS_SCRIPT_PATH_PALAU_DEMO >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_PALAU_DEMO/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" >> "$CRON_JOB_TEMP_FILE"
echo "0 7 * * * node $JS_SCRIPT_PATH_BHUTAN_STAGING >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_BHUTAN_STAGING/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" >> "$CRON_JOB_TEMP_FILE"
echo "0 7 * * * node $JS_SCRIPT_PATH_BHUTAN_DEMO >> $HOME/nautilus-wallet-recurring-payment/logs/$ENV_BHUTAN_DEMO/logfile_\`date +\%F+\%H:\%M:\%S\`.log 2>&1" >> "$CRON_JOB_TEMP_FILE"
# Install the consolidated cron job
crontab "$CRON_JOB_TEMP_FILE"
# Remove the temporary file
rm "$CRON_JOB_TEMP_FILE"
echo "Cron job has been set up successfully."