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
|
#!/usr/bin/bash
|
||||||
[[ -f ~/.bashrc ]] && . .bashrc
|
|
||||||
|
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||||
|
|
||||||
declare -a crontab_dirs=(
|
declare -a crontab_dirs=(
|
||||||
/etc/cron.d
|
/etc/cron.d
|
||||||
@ -8,10 +9,9 @@ declare -a crontab_dirs=(
|
|||||||
/etc/cron.weekly
|
/etc/cron.weekly
|
||||||
/var/spool/cron
|
/var/spool/cron
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -a crontabs_in_db
|
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
|
for name in $( $sqlite_cmd <<< "SELECT crontab_path FROM crontabs;"); do
|
||||||
@ -27,10 +27,10 @@ for dir in ${crontab_dirs[@]}; do
|
|||||||
# path is already stored in the DB
|
# path is already stored in the DB
|
||||||
# if not it will create one and it will be be indexed 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
|
if [[ -f $file ]] && [[ ! "${crontabs_in_db[@]}" == *$file* ]]; then
|
||||||
$sqlite_cmd <<< "
|
$sqlite_cmd "
|
||||||
INSERT INTO crontabs (crontab_path, crontab_data) VALUES
|
INSERT INTO crontabs (crontab_path, crontab_data) VALUES
|
||||||
('$file',
|
('$file',
|
||||||
'$(<$file)')
|
'$($"$(<$file)")');
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -47,13 +47,13 @@ while read crontab_id crontab_path; do
|
|||||||
# this will check to make sure that the file exists on disk and
|
# 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
|
# will compare the disk and db versions of the file to make sure if a change is needed to be
|
||||||
# loaded into the db.
|
# loaded into the db.
|
||||||
if [[ -f $crontab_path ]] && [[ ! "$data" == "$(<$crontab_path)" ]]; then
|
if [[ -f "$crontab_path" ]] && [[ ! "$data" == "$(<$crontab_path)" ]]; then
|
||||||
sqlite3 $WEBCRON_DB <<<"
|
sqlite3 $WEBCRON_DB "
|
||||||
UPDATE crontabs SET crontab_data = '$(<$crontab_path)' WHERE crontab_id = $crontab_id
|
UPDATE crontabs SET crontab_data = '$($"(<$crontab_path)")' WHERE crontab_id = $crontab_id
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done <<< ` sqlite3 $WEBCRON_DB <<< "
|
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