升級docker images, 舊版images變成none

最近升級moodle到4.0.1版本, 發現有問題, 想用回舊版, 發現舊版的變成 moodle:<none> , 這樣一來不就不能使用舊版了, 後來發現只要知道舊版images id , 就可以改成想要的tag, 也就能繼續使用了

docker tag <images id> <images name>:x.x
docker tag 43b9473f010d bitnami/moodle:3.10

使用restic做離線備份, 充滿儀式感,老闆也開心

前陣子發現restic備份的好處, 尤其拿來當離線備份.

IT同事進行離線備份時, 有意無意被老闆路過, 看到滿滿備份畫面咻咻跑來跑去, 充滿了儀式感.
老闆開心, IT同仁也有成就感.


restic指令備份, 不夠自動化, 為了讓IT同事做少少的工作, 又讓IT同事與其他路過的同事覺得好專業, 因此寫了簡單的restic backup script , 可以協助掛載來源目錄, 掛載後,進行restic備份.

檔案請到這裡下載, 下載後請看readme.md檔案

centos 安裝dkim並且自動產生相關文件

先前寫了一篇centos7安裝opendkim+postfix 這只是單一網域, 若要多個網域,實在是很麻煩

google爬文爬到一篇文章,有神人寫了自動產生相關文件的shell script , 我稍微修改一下, 就能很方便產生相關文件.

  • 安裝dkim套件
#centos 7
yum install opendkim
#centos 8 , rocky linux 8
yum install opendkim opendkim-tools
  • 修改 opendkim.conf
    把Mode 改成 sv

postfix寄信認證改用dovecot

一直以來我都讓postfix使用 sasl 方式處裡寄信認證, 但是連結到多網域主控伺服器的時候, 就會出錯, 很麻煩.
經過測試 dovecot 可以使用多組 userdb , 與passdb , 達到一個mail server 支援多個ldap網域主控.

當然也能省下一個sasl的service

  • 修改dovecort的 conf.d/10-master.conf
service auth {
...
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    # Assuming the default Postfix user and group
    user = postfix
    group = postfix
  }
  ...
}

#以下設定為了相容outlook系統
auth_mechanisms = plain login
  • 修改postfix的main.cf
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

# On Debian Wheezy path must be relative and queue_directory defined
#queue_directory = /var/spool/postfix

# and the common settings to enable SASL:
smtpd_sasl_auth_enable = yes
  • 修改postfix的master.cf
submission inet n - n - - smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_sasl_security_options=noanonymous
  -o smtpd_sasl_local_domain=$myhostname
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sender_login_maps=hash:/etc/postfix/virtual
  -o smtpd_sender_restrictions=reject_sender_login_mismatch
 ...

參考:

https://doc.dovecot.org/configuration_manual/howto/postfix_and_dovecot_sasl/

找出當初docker 容器(container)執行的指令(非compose)

 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro assaflavie/runlike  <容器名稱>
docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod <容器名稱>

但是這種方式屬於 reverse 方式, 跟原本會有一些失真,但真的沒留下當初執行的指令, 也只好使用這種方式了

Linux shell script 關於array陣列用法

定義一個陣列

declare -a source_dirs_weekly=("2-w3-portal" "2-w3-opt" "2-w3-jtrac" "200-printer" "194-easyflow" "229-fileserver")

也可以醬

declare -a source_dirs_weekly=(
"2-w3-portal" 
"2-w3-opt" 
"2-w3-jtrac" 
"200-printer" 
"194-easyflow" 
"229-fileserver"
)

要取出資料,可以參考以下的設定, 來源為這 https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays

nextcloud清除垃圾桶與過多的檔案編輯版本

修改 config.php

過了31天清除

 'trashbin_retention_obligation' => 'auto,31',
 'versions_retention_obligation' => 'auto,31',

若使用docker安裝, 建議停用容器內建的排程, 改用外面主機, 設定排程自行刪除垃圾桶

# 停用背景排程
docker exec -t -u www-data <container> php occ config:app:set --value=no files_trashbin background_job_expire_trash

docker exec -t -u www-data nextcloud php occ config:app:set --value=no files_versions background_job_expire_versions
# 停用容器內建排程後,改用外面主機定期清除
docker exec -t -u www-data <container> php occ  trashbin:expire --quiet
1 ... 3 4 5 6 7