Committed for test

This commit is contained in:
Tristan Ancelet 2023-05-15 16:44:17 -05:00
parent bef8309d20
commit d262c17e2e
8 changed files with 188 additions and 3 deletions

View File

@ -51,4 +51,8 @@ CREATE TABLE IF NOT EXISTS crontabs (
crontab_created_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_modified_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_data BLOB NOT NULL
);
);
CREATE VIEW IF NOT EXISTS crontab_exists AS
SELECT a.name, 1 FROM crontabs a WHERE EXISTS (SELECT 1 FROM crontabs b WHERE b.name = a.name);

2
Site

@ -1 +1 @@
Subproject commit 9a1139edaeab309f9cf7eaf4b6431c339638be41
Subproject commit 343a01cf61ae628518215ca5919674ac3f906e3f

View File

@ -28,6 +28,12 @@ declare -a needed_packages=(
apache2
php
# Filesystem Management
acl
# Necessary Project Packages
sqlite3
# Check packages
bind-utils
)
@ -47,6 +53,27 @@ unset needed_packages
# Installing the packages that aren't already installed
apt install -y ${packages_to_install}
# Start: Filesystem Setup
# This will give the webcron user the ability to read, write and execute crontab in all of the regular places
delcare -a crontab_dirs=(
# All of the normal system crontabs are located here
/etc/cron.d
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
# These are the crontabs created by users of the system
/var/spool/cron/crontabs
)
for dir in ${crontab_dirs[@]}; do
# This (while not changing the permissions via chmod)
setfacl -m u:webcron:rwx -R $dir
done
# End: Filesystem Setup
# Start: Firewall Setup
@ -79,6 +106,26 @@ fi
# App Location
WebAppLocation=/opt/WebCron
if [[ ! -d $WebAppLocation ]]; then
# If the webroot directory doesn't exist then create and
# set the www-data user to the owner
mdkir -p $WebAppLocation
# Recursively setting the directory and all subdirectories
# to the www-data user
chown www-data: -R $WebAppLocation
# Setting the filesystem permissions of the directory to only be accessible by the owner
# (excluding the root user of course)
chmod 700 -R $WebAppLocation
cd $WebAppLocation
# Cloning the project repo and it's submodules
git clone https://github.com/TristanAncelet/WebCron
git submodule init
git submodule update
fi
# The IP or IPs that will have access to the web app.
ALLOWED_ACCESS_CONFIG=""
@ -139,11 +186,19 @@ fi
# Enable the site with a2ensite
a2ensite web-cron
a2ensite webcron
[[ $? -ne 0 ]] && log " There was an error when enabling the site, please read the error message, that was provided from the a2ensite command"
# End apache2 config
# Start: DB Work
DB_FILE=$WebAppLocation/webcron.db
if [[ ! -f $DB_FILE ]]; then
query="$( < Database/create-database.sql )"
sqlite3 $DB_FILE <<< "$query"
fi
# End: DB Work
# Start: Enabling Services

45
test.csv Normal file
View File

@ -0,0 +1,45 @@
log_id,log_level_id,log_source,log_message,log_entry_timestamp
1,0,/usr/bin/true,"This is entry 1","2023-05-10 00:57:48"
2,1,/usr/bin/true,"This is entry 2","2023-05-10 00:57:48"
3,0,/usr/bin/true,"This is entry 3","2023-05-10 00:57:48"
4,1,/usr/bin/true,"This is entry 4","2023-05-10 00:57:48"
5,0,/usr/bin/true,"This is entry 5","2023-05-10 00:57:48"
6,1,/usr/bin/true,"This is entry 6","2023-05-10 00:57:48"
7,1,/usr/bin/true,"This is entry 7","2023-05-10 00:57:49"
8,0,/usr/bin/true,"This is entry 8","2023-05-10 00:57:49"
9,0,/usr/bin/true,"This is entry 9","2023-05-10 00:57:49"
10,2,/usr/bin/true,"This is entry 10","2023-05-10 00:57:49"
11,1,/usr/bin/true,"This is entry 11","2023-05-10 00:57:49"
12,0,/usr/bin/true,"This is entry 12","2023-05-10 00:57:49"
13,0,/usr/bin/true,"This is entry 13","2023-05-10 00:57:49"
14,0,/usr/bin/true,"This is entry 14","2023-05-10 00:57:49"
15,2,/usr/bin/true,"This is entry 15","2023-05-10 00:57:49"
16,0,/usr/bin/true,"This is entry 16","2023-05-10 00:57:49"
17,1,/usr/bin/true,"This is entry 17","2023-05-10 00:57:49"
18,1,/usr/bin/true,"This is entry 18","2023-05-10 00:57:49"
19,2,/usr/bin/true,"This is entry 19","2023-05-10 00:57:49"
20,2,/usr/bin/true,"This is entry 20","2023-05-10 00:57:49"
21,0,/usr/bin/true,"This is entry 21","2023-05-10 00:57:49"
22,2,/usr/bin/true,"This is entry 22","2023-05-10 00:57:49"
23,2,/usr/bin/true,"This is entry 23","2023-05-10 00:57:49"
24,1,/usr/bin/true,"This is entry 24","2023-05-10 00:57:49"
25,1,/usr/bin/true,"This is entry 25","2023-05-10 00:57:49"
26,1,/usr/bin/true,"This is entry 26","2023-05-10 00:57:49"
27,1,/usr/bin/true,"This is entry 27","2023-05-10 00:57:49"
28,0,/usr/bin/true,"This is entry 28","2023-05-10 00:57:49"
29,2,/usr/bin/true,"This is entry 29","2023-05-10 00:57:49"
30,2,/usr/bin/true,"This is entry 30","2023-05-10 00:57:49"
31,1,/usr/bin/true,"This is entry 31","2023-05-10 00:57:50"
32,1,/usr/bin/true,"This is entry 32","2023-05-10 00:57:50"
33,0,/usr/bin/true,"This is entry 33","2023-05-10 00:57:50"
34,0,/usr/bin/true,"This is entry 34","2023-05-10 00:57:50"
35,2,/usr/bin/true,"This is entry 35","2023-05-10 00:57:50"
36,1,/usr/bin/true,"This is entry 36","2023-05-10 00:57:50"
37,2,/usr/bin/true,"This is entry 37","2023-05-10 00:57:50"
38,1,/usr/bin/true,"This is entry 38","2023-05-10 00:57:50"
39,1,/usr/bin/true,"This is entry 39","2023-05-10 00:57:50"
40,2,/usr/bin/true,"This is entry 40","2023-05-10 00:57:50"
41,2,/usr/bin/true,"This is entry 41","2023-05-10 00:57:50"
42,0,/usr/bin/true,"This is entry 42","2023-05-10 00:57:50"
43,2,/usr/bin/true,"This is entry 43","2023-05-10 00:57:50"
44,1,/usr/bin/true,"This is entry 44","2023-05-10 00:57:50"
1 log_id log_level_id log_source log_message log_entry_timestamp
2 1 0 /usr/bin/true This is entry 1 2023-05-10 00:57:48
3 2 1 /usr/bin/true This is entry 2 2023-05-10 00:57:48
4 3 0 /usr/bin/true This is entry 3 2023-05-10 00:57:48
5 4 1 /usr/bin/true This is entry 4 2023-05-10 00:57:48
6 5 0 /usr/bin/true This is entry 5 2023-05-10 00:57:48
7 6 1 /usr/bin/true This is entry 6 2023-05-10 00:57:48
8 7 1 /usr/bin/true This is entry 7 2023-05-10 00:57:49
9 8 0 /usr/bin/true This is entry 8 2023-05-10 00:57:49
10 9 0 /usr/bin/true This is entry 9 2023-05-10 00:57:49
11 10 2 /usr/bin/true This is entry 10 2023-05-10 00:57:49
12 11 1 /usr/bin/true This is entry 11 2023-05-10 00:57:49
13 12 0 /usr/bin/true This is entry 12 2023-05-10 00:57:49
14 13 0 /usr/bin/true This is entry 13 2023-05-10 00:57:49
15 14 0 /usr/bin/true This is entry 14 2023-05-10 00:57:49
16 15 2 /usr/bin/true This is entry 15 2023-05-10 00:57:49
17 16 0 /usr/bin/true This is entry 16 2023-05-10 00:57:49
18 17 1 /usr/bin/true This is entry 17 2023-05-10 00:57:49
19 18 1 /usr/bin/true This is entry 18 2023-05-10 00:57:49
20 19 2 /usr/bin/true This is entry 19 2023-05-10 00:57:49
21 20 2 /usr/bin/true This is entry 20 2023-05-10 00:57:49
22 21 0 /usr/bin/true This is entry 21 2023-05-10 00:57:49
23 22 2 /usr/bin/true This is entry 22 2023-05-10 00:57:49
24 23 2 /usr/bin/true This is entry 23 2023-05-10 00:57:49
25 24 1 /usr/bin/true This is entry 24 2023-05-10 00:57:49
26 25 1 /usr/bin/true This is entry 25 2023-05-10 00:57:49
27 26 1 /usr/bin/true This is entry 26 2023-05-10 00:57:49
28 27 1 /usr/bin/true This is entry 27 2023-05-10 00:57:49
29 28 0 /usr/bin/true This is entry 28 2023-05-10 00:57:49
30 29 2 /usr/bin/true This is entry 29 2023-05-10 00:57:49
31 30 2 /usr/bin/true This is entry 30 2023-05-10 00:57:49
32 31 1 /usr/bin/true This is entry 31 2023-05-10 00:57:50
33 32 1 /usr/bin/true This is entry 32 2023-05-10 00:57:50
34 33 0 /usr/bin/true This is entry 33 2023-05-10 00:57:50
35 34 0 /usr/bin/true This is entry 34 2023-05-10 00:57:50
36 35 2 /usr/bin/true This is entry 35 2023-05-10 00:57:50
37 36 1 /usr/bin/true This is entry 36 2023-05-10 00:57:50
38 37 2 /usr/bin/true This is entry 37 2023-05-10 00:57:50
39 38 1 /usr/bin/true This is entry 38 2023-05-10 00:57:50
40 39 1 /usr/bin/true This is entry 39 2023-05-10 00:57:50
41 40 2 /usr/bin/true This is entry 40 2023-05-10 00:57:50
42 41 2 /usr/bin/true This is entry 41 2023-05-10 00:57:50
43 42 0 /usr/bin/true This is entry 42 2023-05-10 00:57:50
44 43 2 /usr/bin/true This is entry 43 2023-05-10 00:57:50
45 44 1 /usr/bin/true This is entry 44 2023-05-10 00:57:50

36
test.file Normal file
View File

@ -0,0 +1,36 @@
crontab_id,crontab_path,crontab_created_timestamp,crontab_modified_timestamp,crontab_data
4,/etc/cron.d/0hourly,"2023-05-10 02:40:31","2023-05-10 02:40:31","# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly"
5,/etc/cron.d/timeshift-hourly,"2023-05-10 02:40:32","2023-05-10 02:40:32","SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""""
0 * * * * root timeshift --check --scripted"
6,/etc/cron.hourly/0anacron,"2023-05-10 02:40:32","2023-05-10 02:40:32","#!/bin/sh
# Check whether 0anacron was run today already
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = ""$day"" ]; then
exit 0
fi
# Do not run jobs when on battery power
online=1
for psupply in /sys/class/power_supply/* ; do
if [ `cat ""$psupply/type"" 2>/dev/null`x = Mainsx ] && [ -f ""$psupply/online"" ]; then
if [ `cat ""$psupply/online"" 2>/dev/null`x = 1x ]; then
online=1
break
else
online=0
fi
fi
done
if [ $online = 0 ]; then
exit 0
fi
/usr/sbin/anacron -s"

45
test.tabs Normal file
View File

@ -0,0 +1,45 @@
log_id log_level_id log_source log_message log_entry_timestamp
1 0 /usr/bin/true This is entry 1 2023-05-10 00:57:48
2 1 /usr/bin/true This is entry 2 2023-05-10 00:57:48
3 0 /usr/bin/true This is entry 3 2023-05-10 00:57:48
4 1 /usr/bin/true This is entry 4 2023-05-10 00:57:48
5 0 /usr/bin/true This is entry 5 2023-05-10 00:57:48
6 1 /usr/bin/true This is entry 6 2023-05-10 00:57:48
7 1 /usr/bin/true This is entry 7 2023-05-10 00:57:49
8 0 /usr/bin/true This is entry 8 2023-05-10 00:57:49
9 0 /usr/bin/true This is entry 9 2023-05-10 00:57:49
10 2 /usr/bin/true This is entry 10 2023-05-10 00:57:49
11 1 /usr/bin/true This is entry 11 2023-05-10 00:57:49
12 0 /usr/bin/true This is entry 12 2023-05-10 00:57:49
13 0 /usr/bin/true This is entry 13 2023-05-10 00:57:49
14 0 /usr/bin/true This is entry 14 2023-05-10 00:57:49
15 2 /usr/bin/true This is entry 15 2023-05-10 00:57:49
16 0 /usr/bin/true This is entry 16 2023-05-10 00:57:49
17 1 /usr/bin/true This is entry 17 2023-05-10 00:57:49
18 1 /usr/bin/true This is entry 18 2023-05-10 00:57:49
19 2 /usr/bin/true This is entry 19 2023-05-10 00:57:49
20 2 /usr/bin/true This is entry 20 2023-05-10 00:57:49
21 0 /usr/bin/true This is entry 21 2023-05-10 00:57:49
22 2 /usr/bin/true This is entry 22 2023-05-10 00:57:49
23 2 /usr/bin/true This is entry 23 2023-05-10 00:57:49
24 1 /usr/bin/true This is entry 24 2023-05-10 00:57:49
25 1 /usr/bin/true This is entry 25 2023-05-10 00:57:49
26 1 /usr/bin/true This is entry 26 2023-05-10 00:57:49
27 1 /usr/bin/true This is entry 27 2023-05-10 00:57:49
28 0 /usr/bin/true This is entry 28 2023-05-10 00:57:49
29 2 /usr/bin/true This is entry 29 2023-05-10 00:57:49
30 2 /usr/bin/true This is entry 30 2023-05-10 00:57:49
31 1 /usr/bin/true This is entry 31 2023-05-10 00:57:50
32 1 /usr/bin/true This is entry 32 2023-05-10 00:57:50
33 0 /usr/bin/true This is entry 33 2023-05-10 00:57:50
34 0 /usr/bin/true This is entry 34 2023-05-10 00:57:50
35 2 /usr/bin/true This is entry 35 2023-05-10 00:57:50
36 1 /usr/bin/true This is entry 36 2023-05-10 00:57:50
37 2 /usr/bin/true This is entry 37 2023-05-10 00:57:50
38 1 /usr/bin/true This is entry 38 2023-05-10 00:57:50
39 1 /usr/bin/true This is entry 39 2023-05-10 00:57:50
40 2 /usr/bin/true This is entry 40 2023-05-10 00:57:50
41 2 /usr/bin/true This is entry 41 2023-05-10 00:57:50
42 0 /usr/bin/true This is entry 42 2023-05-10 00:57:50
43 2 /usr/bin/true This is entry 43 2023-05-10 00:57:50
44 1 /usr/bin/true This is entry 44 2023-05-10 00:57:50