Fixed issue loading files into webcron.db. Had to add $"..." to the section loading the file in to ensure it didn't try loading the bash variables & functions, etc causing the script to fail
This commit is contained in:
parent
f561296568
commit
00ea4ef63d
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/bash
|
||||
[[ -f ~/.bashrc ]] && . .bashrc
|
||||
|
||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||
|
||||
declare -a crontab_dirs=(
|
||||
/etc/cron.d
|
||||
@ -7,11 +8,10 @@ declare -a crontab_dirs=(
|
||||
/etc/cron.hourly
|
||||
/etc/cron.weekly
|
||||
/var/spool/cron
|
||||
)
|
||||
|
||||
)
|
||||
declare -a crontabs_in_db
|
||||
|
||||
sqlite_cmd='sqlite3 $WEBCRON_DB'
|
||||
sqlite_cmd="sqlite3 $WEBCRON_DB"
|
||||
|
||||
|
||||
for name in $( $sqlite_cmd <<< "SELECT crontab_path FROM crontabs;"); do
|
||||
@ -27,11 +27,11 @@ for dir in ${crontab_dirs[@]}; do
|
||||
# path is already stored in the DB
|
||||
# if not it will create one and it will be be indexed in the DB
|
||||
if [[ -f $file ]] && [[ ! "${crontabs_in_db[@]}" == *$file* ]]; then
|
||||
$sqlite_cmd <<< "
|
||||
$sqlite_cmd "
|
||||
INSERT INTO crontabs (crontab_path, crontab_data) VALUES
|
||||
('$file',
|
||||
'$(<$file)')
|
||||
"
|
||||
'$($"$(<$file)")');
|
||||
"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -47,13 +47,13 @@ while read crontab_id crontab_path; do
|
||||
# this will check to make sure that the file exists on disk and
|
||||
# will compare the disk and db versions of the file to make sure if a change is needed to be
|
||||
# loaded into the db.
|
||||
if [[ -f $crontab_path ]] && [[ ! "$data" == "$(<$crontab_path)" ]]; then
|
||||
sqlite3 $WEBCRON_DB <<<"
|
||||
UPDATE crontabs SET crontab_data = '$(<$crontab_path)' WHERE crontab_id = $crontab_id
|
||||
if [[ -f "$crontab_path" ]] && [[ ! "$data" == "$(<$crontab_path)" ]]; then
|
||||
sqlite3 $WEBCRON_DB "
|
||||
UPDATE crontabs SET crontab_data = '$($"(<$crontab_path)")' WHERE crontab_id = $crontab_id
|
||||
"
|
||||
fi
|
||||
|
||||
done <<< ` sqlite3 $WEBCRON_DB <<< "
|
||||
SELECT crontab_id crontab_name, crontab_path FROM crontabs;
|
||||
SELECT crontab_id, crontab_path FROM crontabs;
|
||||
" `
|
||||
unset IFS
|
||||
unset IFS
|
||||
|
Loading…
Reference in New Issue
Block a user