Rename project to UploadShield: update runtime, configs, docs, and provisioning; run lint/tests
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
- hosts: web
|
||||
become: true
|
||||
vars:
|
||||
upload_logger_root: "{{ playbook_dir | default('.') | dirname | realpath }}"
|
||||
logs_dir: "{{ upload_logger_root }}/logs"
|
||||
quarantine_dir: "{{ upload_logger_root }}/quarantine"
|
||||
state_dir: "{{ upload_logger_root }}/state"
|
||||
examples_dir: "{{ upload_logger_root }}/examples"
|
||||
uploadshield_root: "{{ playbook_dir | default('.') | dirname | realpath }}"
|
||||
logs_dir: "{{ uploadshield_root }}/logs"
|
||||
quarantine_dir: "{{ uploadshield_root }}/quarantine"
|
||||
state_dir: "{{ uploadshield_root }}/state"
|
||||
examples_dir: "{{ uploadshield_root }}/examples"
|
||||
quarantine_owner: "root"
|
||||
quarantine_group: "www-data"
|
||||
quarantine_perms: "0700"
|
||||
@@ -17,8 +17,8 @@
|
||||
logs_perms: "0750"
|
||||
log_file_mode: "0640"
|
||||
selinux_fcontext: "httpd_sys_rw_content_t"
|
||||
tmpfiles_conf: "/etc/tmpfiles.d/upload-logger.conf"
|
||||
logrotate_dest: "/etc/logrotate.d/upload-logger"
|
||||
tmpfiles_conf: "/etc/tmpfiles.d/uploadshield.conf"
|
||||
logrotate_dest: "/etc/logrotate.d/uploadshield"
|
||||
|
||||
tasks:
|
||||
- name: Ensure logs directory exists
|
||||
@@ -45,14 +45,14 @@
|
||||
group: "{{ quarantine_group }}"
|
||||
mode: "{{ state_perms }}"
|
||||
|
||||
- name: Ensure example upload-logger.json is copied (only when missing)
|
||||
- name: Ensure example uploadshield.json is copied (only when missing)
|
||||
copy:
|
||||
src: "{{ examples_dir }}/upload-logger.json"
|
||||
dest: "{{ upload_logger_root }}/upload-logger.json"
|
||||
src: "{{ examples_dir }}/uploadshield.json"
|
||||
dest: "{{ uploadshield_root }}/uploadshield.json"
|
||||
owner: "{{ quarantine_owner }}"
|
||||
group: "{{ quarantine_group }}"
|
||||
mode: "0644"
|
||||
when: not (upload_logger_root + '/upload-logger.json') | path_exists
|
||||
when: not (uploadshield_root + '/uploadshield.json') | path_exists
|
||||
|
||||
- name: Install tmpfiles.d entry to recreate dirs at boot
|
||||
copy:
|
||||
@@ -66,12 +66,12 @@
|
||||
|
||||
- name: Install logrotate snippet if example exists
|
||||
copy:
|
||||
src: "{{ examples_dir }}/logrotate.d/upload-logger"
|
||||
src: "{{ examples_dir }}/logrotate.d/uploadshield"
|
||||
dest: "{{ logrotate_dest }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
when: (examples_dir + '/logrotate.d/upload-logger') | path_exists
|
||||
when: (examples_dir + '/logrotate.d/uploadshield') | path_exists
|
||||
|
||||
- name: Set SELinux fcontext for directories when selinux enabled
|
||||
when: ansible_selinux.status == 'enabled'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
# Ansible playbook snippet to provision UploadShield directories and permissions.
|
||||
# Usage: ansible-playbook -i inventory scripts/ansible/upload-logger-provision.yml
|
||||
# Usage: ansible-playbook -i inventory scripts/ansible/uploadshield-provision.yml
|
||||
|
||||
- hosts: web
|
||||
become: true
|
||||
vars:
|
||||
upload_logger_root: "{{ playbook_dir | default('.') | dirname | realpath }}"
|
||||
quarantine_dir: "{{ upload_logger_root }}/quarantine"
|
||||
state_dir: "{{ upload_logger_root }}/state"
|
||||
uploadshield_root: "{{ playbook_dir | default('.') | dirname | realpath }}"
|
||||
quarantine_dir: "{{ uploadshield_root }}/quarantine"
|
||||
state_dir: "{{ uploadshield_root }}/state"
|
||||
quarantine_owner: "root"
|
||||
quarantine_group: "www-data"
|
||||
quarantine_perms: "0700"
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Provision quarantine and state directories for UploadShield (upload-logger.php)
|
||||
# Usage: sudo ./provision_dirs.sh [--config path/to/upload-logger.json]
|
||||
# Provision quarantine and state directories for UploadShield (uploadshield.php)
|
||||
# Usage: sudo ./provision_dirs.sh [--config path/to/uploadshield.json]
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
CFG="${1:-$ROOT_DIR/upload-logger.json}"
|
||||
CFG="${1:-$ROOT_DIR/uploadshield.json}"
|
||||
|
||||
QUIET=0
|
||||
if [[ "${2:-}" == "--quiet" ]]; then QUIET=1; fi
|
||||
@@ -85,7 +85,7 @@ else
|
||||
fi
|
||||
|
||||
# Optional tmpfiles.d entry to recreate directories at boot (idempotent)
|
||||
TMPFILE="/etc/tmpfiles.d/upload-logger.conf"
|
||||
TMPFILE="/etc/tmpfiles.d/uploadshield.conf"
|
||||
if [[ -w /etc/tmpfiles.d || $QUIET -eq 1 ]]; then
|
||||
info "Writing tmpfiles.d entry to ${TMPFILE}"
|
||||
cat > "$TMPFILE" <<EOF
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
set -euo pipefail
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
ACTIVE_CFG="$ROOT_DIR/upload-logger.json"
|
||||
PROD_CFG="$ROOT_DIR/config/upload-logger.prod.json"
|
||||
BLOCK_CFG="$ROOT_DIR/config/upload-logger.blocking.json"
|
||||
ACTIVE_CFG="$ROOT_DIR/uploadshield.json"
|
||||
PROD_CFG="$ROOT_DIR/config/uploadshield.prod.json"
|
||||
BLOCK_CFG="$ROOT_DIR/config/uploadshield.blocking.json"
|
||||
BACKUP_DIR="$ROOT_DIR/config/backups"
|
||||
DRY_RUN=0
|
||||
CONFIRM=0
|
||||
@@ -46,8 +46,8 @@ fi
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
TS=$(date +%Y%m%dT%H%M%S)
|
||||
if [[ -f "$ACTIVE_CFG" ]]; then
|
||||
cp -a "$ACTIVE_CFG" "$BACKUP_DIR/upload-logger.json.bak.$TS"
|
||||
echo "Backed up current config to $BACKUP_DIR/upload-logger.json.bak.$TS"
|
||||
cp -a "$ACTIVE_CFG" "$BACKUP_DIR/uploadshield.json.bak.$TS"
|
||||
echo "Backed up current config to $BACKUP_DIR/uploadshield.json.bak.$TS"
|
||||
fi
|
||||
|
||||
cp -a "$BLOCK_CFG" "$ACTIVE_CFG"
|
||||
|
||||
@@ -4,7 +4,7 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/upload-logger-provision.sh /opt/upload-logger/upload-logger.json
|
||||
ExecStart=/usr/local/bin/uploadshield-provision.sh /opt/uploadshield/uploadshield.json
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
Reference in New Issue
Block a user