Skip to content

Commit

Permalink
added cron job installation
Browse files Browse the repository at this point in the history
  • Loading branch information
nemerald-voip committed Dec 13, 2024
1 parent a2844f2 commit a5eb33e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion database/seeders/RecommendedSettingsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private function createDefaultSettings()
'default_setting_category' => 'mobile_apps',
'default_setting_subcategory' => 'mobile_app_conn_protocol',
'default_setting_name' => 'text',
'default_setting_value' => 'sips',
'default_setting_value' => 'sip',
'default_setting_enabled' => true,
'default_setting_description' => "Options: sip or tcp or sips",
],
Expand Down
9 changes: 9 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ else
exit 1
fi

# Include the install_cron_jobs.sh script
sh /var/www/fspbx/install/install_cron_jobs.sh
if [ $? -eq 0 ]; then
print_success "Cron bob installation script executed successfully."
else
print_error "Error occurred while executing cron job installation script."
exit 1
fi

# Include the add_web_server_to_sudoers.sh script
sh /var/www/fspbx/install/add_web_server_to_sudoers.sh
if [ $? -eq 0 ]; then
Expand Down
42 changes: 42 additions & 0 deletions install/install_cron_jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# Function to print success message
print_success() {
echo "\033[32m$1 \033[0m" # Green text
}

# Function to print error message
print_error() {
echo "\033[31m$1 \033[0m" # Red text
}

# Define the cron job entries as a string
CRON_JOBS="
* * * * * cd /var/www/fspbx; /usr/bin/php /var/www/fspbx/public/app/xml_cdr/xml_cdr_import.php 100 abcdef >/dev/null 2>&1
* * * * * cd /var/www/fspbx; /usr/bin/php /var/www/fspbx/public/app/xml_cdr/xml_cdr_import.php 100 01234 >/dev/null 2>&1
* * * * * cd /var/www/fspbx; /usr/bin/php /var/www/fspbx/public/app/xml_cdr/xml_cdr_import.php 100 56789 >/dev/null 2>&1
* * * * * cd /var/www/fspbx && php artisan schedule:run >> /dev/null 2>&1
"

# Backup the existing crontab
CRON_FILE=$(mktemp)
crontab -l > "$CRON_FILE" 2>/dev/null || true

# Loop through each cron job and add it if it doesn't exist
echo "$CRON_JOBS" | while read -r job; do
if [ -n "$job" ] && ! grep -Fxq "$job" "$CRON_FILE"; then
echo "$job" >> "$CRON_FILE"
echo "Added cron job: $job"
else
echo "Cron job already exists: $job"
fi
done

# Apply the updated crontab
crontab "$CRON_FILE" && rm "$CRON_FILE"
if [ $? -eq 0 ]; then
print_success "Cron jobs updated successfully."
else
print_error "Failed to update cron jobs."
exit 1
fi

0 comments on commit a5eb33e

Please sign in to comment.