remove problematic tasks from ansible and define a post-install script

This commit is contained in:
2024-12-03 16:47:24 +01:00
parent 9031ce55b5
commit 2cbec8e59f
6 changed files with 81 additions and 39 deletions

61
post-install.sh Normal file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# ------------------ Variables ----------------------- #
my_domain="owncloud.softbox.net"
my_ip=$(hostname -I | cut -f1 -d ' ')
database="mysql"
database_name="owncloud"
database_user="owncloud"
database_pass=""
data_dir="/var/www/owncloud/data"
admin_user="root"
admin_pass=""
# --------------------------------------------------- #
# Exit if not run as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
# Install owncloud
occ maintenance:install --database "$database" --database-name "$database_name" --database-user "$database_user" --database-pass "$database_pass" --data-dir "$data_dir" --admin-user "$admin_user" --admin-pass "$admin_pass"
# Set trusted domains
occ config:system:set trusted_domains 1 --value="$my_ip"
occ config:system:set trusted_domains 2 --value="$my_domain"
# Set background job mode to cron
occ background:cron
# Set the execution of two cron jobs
echo "*/15 * * * * /var/www/owncloud/occ system:cron" |
sudo -u www-data -g crontab tee -a \
/var/spool/cron/crontabs/www-data
echo "0 2 * * * /var/www/owncloud/occ dav:cleanup-chunks" |
sudo -u www-data -g crontab tee -a \
/var/spool/cron/crontabs/www-data
# Sync with LDAP server
echo "1 */6 * * * /var/www/owncloud/occ user:sync \
'OCA\User_LDAP\User_Proxy' -m disable -vvv >> \
/var/log/ldap-sync/user-sync.log 2>&1" |
sudo -u www-data -g crontab tee -a \
/var/spool/cron/crontabs/www-data
mkdir -p /var/log/ldap-sync
touch /var/log/ldap-sync/user-sync.log
chown www-data. /var/log/ldap-sync/user-sync.log
# Configure Caching and File Locking
occ config:system:set \
memcache.local \
--value '\OC\Memcache\APCu'
occ config:system:set \
memcache.locking \
--value '\OC\Memcache\Redis'
occ config:system:set \
redis \
--value '{"host": "127.0.0.1", "port": "6379"}' \
--type json
systemctl restart apache2

View File

@@ -1,9 +1,9 @@
- name: Configure Caching and File locking
command: "{{ item }}"
loop: >
- occ config:system:set memcache.local --value '\OC\Memcache\APCu'
- occ config:system:set memcache.locking --value '\OC\Memcache\Redis'
- occ config:system:set redis --value '{"host": "127.0.0.1", "port": "6379"}' --type json
#- name: Configure Caching and File locking
# command: "{{ item }}"
# loop: >
# - occ config:system:set memcache.local --value '\OC\Memcache\APCu'
# - occ config:system:set memcache.locking --value '\OC\Memcache\Redis'
# - occ config:system:set redis --value '{"host": "127.0.0.1", "port": "6379"}' --type json
- name: Configure Log Rotation.
template:

View File

@@ -1,19 +0,0 @@
- name: Set background job mode to cron.
commmand: occ background:cron
- name: Set the exectution of cron jobs to every 15 min.
ansible.builtin.cron:
name: "exe cron."
minute: "*/15"
user: www-data
job: "/var/www/owncloud/occ system:cron"
state: present
- name: Cleanup of chunks every night at 2am.
ansible.builtin.cron:
name: "cleanup chunks."
minute: "0"
hour: "2"
user: www-data
job: "/var/www/owncloud/occ dav:cleanup-chunks"
state: present

View File

@@ -53,6 +53,7 @@
- inetutils-ping
- ldap-utils
- smbclient
- cron
#- name: Disable the firewall (since this is behind a firewall)
# service: name=ufw state=stopped

View File

@@ -23,9 +23,9 @@
include_tasks:
file: owncloud.yml
- name: Configure Cronjobs.
include_tasks:
file: cron.yml
#- name: Configure Cronjobs.
# include_tasks:
# file: cron.yml
- name: Configure ownCloud.
include_tasks:

View File

@@ -11,14 +11,13 @@
dest: "/var/www/"
owner: www-data
remote_src: yes
- name: Install ownCloud (via occ)
command: >
occ maintenance:install --database "mysql" --database-name "owncloud" --database-user "owncloud" --database-pass "{{ mysql_passwd }}" --data-dir "{{ owncloud_core_path }}/data" --admin-user "root" --admin-pass "{{ mysql_passwd }}"
- name: Configure ownCloud's trusted domains
command: "{{ item }}"
loop:
- my_ip=$(hostname -I|cut -f1 -d ' ')
- occ config:system:set trusted_domains 1 --value="$my_ip"
- occ config:system:set trusted_domains 2 --value="{{ hostname }}"
#- name: Install ownCloud (via occ)
# command: >
# occ maintenance:install --database "mysql" --database-name "owncloud" --database-user "owncloud" --database-pass "{{ mysql_passwd }}" --data-dir "{{ owncloud_core_path }}/data" --admin-user "root" --admin-pass "{{ mysql_passwd }}"
#
#- name: Configure ownCloud's trusted domains
# command: "{{ item }}"
# loop:
# - my_ip=$(hostname -I|cut -f1 -d ' ')
# - occ config:system:set trusted_domains 1 --value="$my_ip"
# - occ config:system:set trusted_domains 2 --value="{{ hostname }}"