287 lines
9.7 KiB
Org Mode
Executable File
287 lines
9.7 KiB
Org Mode
Executable File
:PROPERTIES:
|
|
:ID: 56f39be4-1108-4020-be5a-1f3a0fbf96fa
|
|
:END:
|
|
#+title: Nextcloud
|
|
#+filetags: :self-hosting:
|
|
|
|
* The docker file:
|
|
|
|
#+begin_src bash
|
|
|
|
version: '3.8'
|
|
services:
|
|
app:
|
|
image: nextcloud
|
|
restart: unless-stopped
|
|
ports:
|
|
- 8007:80
|
|
volumes:
|
|
- nextcloud:/var/www/html
|
|
environment:
|
|
- POSTGRES_DB=nextcloud
|
|
- POSTGRES_USER=nextcloud
|
|
- POSTGRES_PASSWORD=zxq123_nextcloud
|
|
- POSTGRES_HOST=postgres
|
|
networks:
|
|
- postgres_network
|
|
|
|
volumes:
|
|
nextcloud:
|
|
|
|
networks:
|
|
postgres_network:
|
|
external: true
|
|
|
|
#+end_src
|
|
|
|
* Database related things:
|
|
|
|
#+begin_src bash
|
|
|
|
zxq_db=# CREATE DATABASE nextcloud;
|
|
CREATE DATABASE
|
|
zxq_db=# CREATE USER nextcloud WITH PASSWORD 'zxq123_nextcloud';
|
|
CREATE ROLE
|
|
zxq_db=# GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
|
|
GRANT
|
|
zxq_db=#
|
|
|
|
#+end_src
|
|
|
|
|
|
* Permissions:
|
|
|
|
** *Not sure if the below still applies*
|
|
#+begin_src bash
|
|
|
|
# Add yourself and www-data to a shared group
|
|
|
|
### Create a shared group:
|
|
|
|
sudo groupadd ncshare
|
|
|
|
### Add both users:
|
|
|
|
sudo usermod -aG ncshare zaine
|
|
sudo usermod -aG ncshare www-data
|
|
|
|
### Set the folder to that group:
|
|
|
|
sudo chown -R zaine:ncshare /home/zaine/master-folder
|
|
sudo chmod -R 775 /home/zaine/master-folder
|
|
|
|
|
|
#+end_src
|
|
|
|
** <2026-03-25 Wed> fixes:
|
|
|
|
Up To Date Fixes:
|
|
We need to add zaine to the www-data group:
|
|
|
|
#+begin_src bash
|
|
sudo usermod -aG www-data zaine
|
|
#+end_src
|
|
|
|
Then we need to make the directories setgid, so that any new files created will have the group www-data:
|
|
|
|
#+begin_src bash
|
|
sudo chown -R zaine:www-data /home/zaine/master-folder
|
|
sudo chmod -R 2775 /home/zaine/master-folder # the 2 sets the setgid bit, which means that new files will inherit the group of the directory, which is www-data
|
|
#+end_src
|
|
|
|
*** Older fixes
|
|
So apparently, nextcloud needs to have www-data as the owner of the files, and to do that, we need to run the following command:
|
|
|
|
#+begin_src bash
|
|
sudo chown -R www-data:www-data /home/zaine/master-folder
|
|
#+end_src
|
|
|
|
I modified the build scripts to change permissions back to zaine:zaine when deleting the output folder, then changing it back to www-data:www-data.
|
|
|
|
One other useful thing may be:
|
|
|
|
#+begin_src bash
|
|
|
|
docker exec -u 1000:1000 -it nextcloud-app-1 php occ files:scan --all
|
|
|
|
# or
|
|
|
|
docker exec -u 1000 nextcloud-app-1 php occ files:scan --path="zaine/files/master-folder"
|
|
|
|
#+end_src
|
|
|
|
One other thing:
|
|
|
|
#+begin_src bash
|
|
i FIXED IT BY doing this:
|
|
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [09:47:47] [~/docker-services/nextcloud]
|
|
-> % docker exec -it postgres psql -U nextcloud -d nextcloud
|
|
psql (17.5 (Debian 17.5-1.pgdg120+1))
|
|
Type "help" for help.
|
|
|
|
nextcloud=> SELECT * FROM oc_file_locks;
|
|
nextcloud=> DELETE FROM oc_file_locks;
|
|
DELETE 15002
|
|
nextcloud=> \q
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [09:49:01] [~/docker-services/nextcloud]
|
|
-> % docker exec -it nextcloud-app-1 ls /mnt/master-folder
|
|
alimiyyah attachments booking career hurra.txt org_files pdfs projects uni
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [09:49:04] [~/docker-services/nextcloud]
|
|
-> % docker exec -u 1000 -it nextcloud-app-1 php occ files:scan --all
|
|
Starting scan for user 1 out of 2 (halima)
|
|
Starting scan for user 2 out of 2 (zaine)
|
|
+---------+-------+-----+---------+---------+--------+--------------+
|
|
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
|
|
+---------+-------+-----+---------+---------+--------+--------------+
|
|
| 1985 | 12906 | 0 | 522 | 0 | 0 | 00:00:50 |
|
|
+---------+-------+-----+---------+---------+--------+--------------+
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [09:49:59] [~/docker-services/nextcloud]
|
|
-> %
|
|
|
|
there is some issue in the nextcloud permissions itself. if i create a file and delete it in windows, i get this error in the client: A
|
|
master-folder/hehe.txt
|
|
now
|
|
The resource you are trying to access is currently locked and cannot be modified. Please try changing it later, or contact your server administrator ...
|
|
|
|
and if i try to delete it in nextcloud ui (web), it says file cant be deleted
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Config
|
|
|
|
Location is:
|
|
|
|
sudo nano /var/lib/docker/volumes/nextcloud_nextcloud/_data/config/config.php
|
|
|
|
* Accounts
|
|
User is: zaine
|
|
Pass: Shakkal123!
|
|
|
|
* Legacy stuff
|
|
Something I've been trying to reverse proxy ahead of time. Go to https://zserver.zapto.org/nextcloud , you'll be prompted to login with a username and password:
|
|
Here's your credentials:
|
|
|
|
Username: halima
|
|
Password: loser2104!
|
|
|
|
Once you've logged in, I've set up your account already, so there should be a calendar already there.
|
|
|
|
To get your phone logged in, there's two ways:
|
|
1) go to the following address: https://zserver.zapto.org/nextcloud/settings/user/security , scroll to the bottom, under devices and sessions, type in a random name (iphone), and click create new app password. You should then be able to generate a QR code (next to or under the password field), then you can scan that on your iphone app.
|
|
|
|
2) inside the app, type the following URL: https://zserver.zapto.org/nextcloud then follow the instructions.
|
|
|
|
Im thinking of having this as our shared calendar and file system. The only users are us 2 and its completely off the internet (self-hosted).
|
|
|
|
|
|
** network issues resolved by:
|
|
|
|
#+begin_src bash
|
|
|
|
docker network connect postgres_network postgres
|
|
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [21:00:27] [~/docker-services/nextcloud]
|
|
-> % psql -h zserver.zapto.org -p 5432 -U zaine -d zxq_db
|
|
Password for user zaine:
|
|
psql (14.18 (Ubuntu 14.18-0ubuntu0.22.04.1), server 17.5 (Debian 17.5-1.pgdg120+1))
|
|
WARNING: psql major version 14, server major version 17.
|
|
Some psql features might not work.
|
|
Type "help" for help.
|
|
|
|
zxq_db=# \c nextcloud
|
|
psql (14.18 (Ubuntu 14.18-0ubuntu0.22.04.1), server 17.5 (Debian 17.5-1.pgdg120+1))
|
|
WARNING: psql major version 14, server major version 17.
|
|
Some psql features might not work.
|
|
You are now connected to database "nextcloud" as user "zaine".
|
|
nextcloud=# GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
|
|
GRANT
|
|
nextcloud=# GRANT USAGE ON SCHEMA public TO nextcloud;
|
|
GRANT CREATE ON SCHEMA public TO nextcloud;
|
|
GRANT
|
|
GRANT
|
|
nextcloud=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO nextcloud;
|
|
GRANT
|
|
nextcloud=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO nextcloud;
|
|
GRANT
|
|
nextcloud=#
|
|
|
|
zaine
|
|
M22ZN-fmefj-RdF36-3BMfT-LfWo8
|
|
|
|
zaine
|
|
zxh123!
|
|
|
|
#+end_src
|
|
|
|
** Connecting to IOS
|
|
https://www.reddit.com/r/NextCloud/comments/1pehpft/calendar_app_for_ios/
|
|
|
|
* ICS stuff:
|
|
|
|
** To get the ID of a calendar subscription:
|
|
|
|
#+begin_src
|
|
zaine@zaine-HP-ProDesk-400-G1-SFF [14:14:27] [~]
|
|
-> % docker exec nextcloud-app-1 php occ dav:list-subscriptions zaine
|
|
+-----------------------+-----------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| URI | Displayname | Refresh rate | Source |
|
|
+-----------------------+-----------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| outlookoffice365com-1 | outlook.office365.com | PT5M (default) | https://outlook.office365.com/owa/calendar/b910ea835e414663831e505f3d10baa2@microlise.com/d2568a0134fb49af92d39c1669c4729317662288011094411305/calendar.ics |
|
|
+-----------------------+-----------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
|
|
#+end_src
|
|
|
|
** emacs config to sync calendars:
|
|
|
|
#+begin_src
|
|
(require 'org-caldav)
|
|
(require 'url)
|
|
(require 'icalendar)
|
|
(modify-coding-system-alist 'file "caldav-work\\.org\\'" 'utf-8-unix)
|
|
(defvar my/outlook-ics-url
|
|
"https://outlook.office365.com/owa/calendar/b910ea835e414663831e505f3d10baa2@microlise.com/d2568a0134fb49af92d39c1669c4729317662288011094411305/calendar.ics")
|
|
|
|
(defvar my/outlook-org-file
|
|
"D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-work.org")
|
|
|
|
(defvar my/ics-python-script
|
|
"D:\\_nextcloud\\master-folder\\org_files\\calendar\\ics_to_org.py")
|
|
|
|
(defun my/sync-outlook-calendar ()
|
|
"Fetch and expand Outlook ICS (including recurrences) into org file."
|
|
(interactive)
|
|
(message "Syncing Outlook calendar...")
|
|
(let* ((cmd (format "python \"%s\" \"%s\" \"%s\""
|
|
my/ics-python-script
|
|
my/outlook-ics-url
|
|
my/outlook-org-file))
|
|
(result (shell-command-to-string cmd)))
|
|
(message "Outlook calendar sync: %s" (string-trim result))))
|
|
|
|
;; Sync on startup and every 30 minutes
|
|
(my/sync-outlook-calendar)
|
|
(run-with-timer (* 30 60) (* 30 60) #'my/sync-outlook-calendar)
|
|
;; --- CalDAV for native Nextcloud calendars ---
|
|
(setq org-caldav-url "https://nextcloud.zainezq.com/remote.php/dav/calendars/zaine/")
|
|
(setq org-caldav-calendars
|
|
'((:calendar-id "personal"
|
|
:inbox "D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-personal.org"
|
|
:files nil)
|
|
(:calendar-id "zxh"
|
|
:inbox "D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-family.org"
|
|
:files nil)))
|
|
|
|
;; --- Agenda files ---
|
|
(setq org-agenda-files
|
|
'("D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-personal.org"
|
|
"D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-work.org"
|
|
"D:\\_nextcloud\\master-folder\\org_files\\calendar\\caldav-family.org"
|
|
"D:\\_nextcloud\\master-folder\\org_files\\org_roam\\Books\\20250724230557-books_org_agenda.org"))
|
|
|
|
|
|
#+end_src
|