本篇並無一步一步地教學如何設定 Home Assistant 以將 Gmail 通知發送到 LINE,而是特別關注如何正確處理換行字元(“\n”)。這個看似簡單的需求,可能會由於 YAML、JSON 和各種 API 之間的複雜性而帶來許多頭痛的問題。
篇幅將專注在如何確保 LINE 訊息中的換行字元號正確顯示的問題。繼續閱讀...
本篇並無一步一步地教學如何設定 Home Assistant 以將 Gmail 通知發送到 LINE,而是特別關注如何正確處理換行字元(“\n”)。這個看似簡單的需求,可能會由於 YAML、JSON 和各種 API 之間的複雜性而帶來許多頭痛的問題。
篇幅將專注在如何確保 LINE 訊息中的換行字元號正確顯示的問題。繼續閱讀...
這篇文章將介紹如何將 Aegis Authenticator 中的明文 JSON 資料匯出並轉換為 PowertoysRunTOTP 所需的格式,幫助你將雙因素驗證(2FA)帳號從 Aegis 匯入到 PowerToys Run TOTP 擴充套件中。
警告:請勿將明文 JSON 文件長時間保留在電腦中。建議將其存放在加密的存儲空間中,如 pCloud Crypto,或者使用 7zip 壓縮並設置安全密碼來保護文件。
首先,從 Aegis Authenticator 中匯出你的 2FA 帳號資料。確保匯出的文件是明文 JSON 格式,並保存到一個安全的位置,例如 C:\path\to\aegis_export.json。
編寫一個 PowerShell 腳本來轉換 Aegis 匯出的 JSON 文件為 PowertoysRunTOTP 所需的格式。以下是完整的腳本,你可以用記事本複製貼上,並儲存為 .ps1 檔案例如 convert_aegis_to_powertoysrun.ps1。
$inputFilePath = "P:\Crypto Folder\aegis.json"
$outputFilePath = "$env:LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Community.PowerToys.Run.Plugin.TOTP\OTPList.json_new"
try {
# Read the Aegis JSON file and ensure it uses UTF-8 encoding
$jsonContent = Get-Content -Raw -Path $inputFilePath -Encoding UTF8
# Check if the JSON file is empty
if ($jsonContent -eq $null -or $jsonContent.Trim() -eq "") {
throw "The Aegis JSON file is empty or contains no content"
}
try {
# Parse the JSON file
$aegisData = $jsonContent | ConvertFrom-Json
} catch {
throw "JSON parsing error: $_"
}
# Prepare the JSON structure for PowerToysRunTOTP
$powerToysRunTOTP = @{
Version = 2
Entries = @()
}
# Check the structure of the Aegis JSON file
if ($aegisData.db.entries -ne $null) {
# Iterate over Aegis entries and extract necessary data
foreach ($entry in $aegisData.db.entries) {
$newEntry = @{
Name = "$($entry.issuer): $($entry.name)"
Key = $entry.info.secret
IsEncrypted = $false
}
$powerToysRunTOTP.Entries += $newEntry
}
} else {
throw "Entries in the Aegis JSON file are empty or not found"
}
# Write the converted data to the PowerToysRunTOTP JSON file
$powerToysRunTOTP | ConvertTo-Json -Depth 3 | Set-Content -Path $outputFilePath -Encoding UTF8
Write-Host "Aegis JSON conversion successful and saved to $outputFilePath"
} catch {
Write-Host "An error occurred during the conversion process: $_"
}
convert_aegis_to_powertoysrun.ps1。Win + X 鍵,選擇「Windows PowerShell(管理員)」或「Windows 終端機(管理員)」。PowerShell -ExecutionPolicy Bypass -File
PowerShell -ExecutionPolicy Bypass -File "C:\path\to\convert_aegis_to_powertoysrun.ps1"
通過以上步驟,我們成功地將 Aegis Authenticator 匯出的明文 JSON 文件轉換並匯入到 PowertoysRunTOTP 中。這種方法可以幫助你輕鬆地管理你的 2FA 帳號,並在不同的裝置之間進行遷移。
如果你覺得文章對你有幫助,歡迎在下方留言、按下笑臉或分享給其他人知道。
若有相關的建議也歡迎留言!
推薦 Portainer 方便圖形化管理
若擔心 latest 會每次 pull 重新部署就弄壞的話,就自己挑選合適版本號定下來。
version: "4.5"
services:
tsumugi-db:
image: mariadb:latest
volumes:
- tsumugi-mariadb_data:/var/lib/mysql
restart: always
environment:
MARIADB_ROOT_PASSWORD: your-mariadb-root-pwd
MARIADB_DATABASE: your-wordpress-db
MARIADB_USER: yourDbUserForWp
MARIADB_PASSWORD: yourMariaDbPassword
tsumugi-wordpress:
depends_on:
- tsumugi-db
#links:
# - mariadb:mysql
image: wordpress:latest
volumes:
- tsumugi-wordpress_data:/var/www/html
- tsumugi-wordpress_php:/usr/local/etc/php
restart: always
environment:
WORDPRESS_DB_HOST: tsumugi-db
WORDPRESS_DB_USER: yourDbUserForWp
WORDPRESS_DB_PASSWORD: yourMariaDbPassword
WORDPRESS_DB_NAME: your-wordpress-db
zunda-db:
image: mariadb:latest
volumes:
- zundamon-mariadb_data:/var/lib/mysql
restart: always
environment:
MARIADB_ROOT_PASSWORD: some-mariadb-root-pwd
MARIADB_DATABASE: zundamon-wordpress
MARIADB_USER: zundamochi114514
MARIADB_PASSWORD: some-mariadb-password
zundamon-wordpress:
depends_on:
- zunda-db
image: wordpress:latest
volumes:
- zundamon-wordpress_data:/var/www/html
- zundamon-wordpress_php:/usr/local/etc/php
restart: always
environment:
WORDPRESS_DB_HOST: zunda-db
WORDPRESS_DB_USER: zundamochi114514
WORDPRESS_DB_PASSWORD: some-mariadb-password
WORDPRESS_DB_NAME: zundamon-wordpress
WORDPRESS_TABLE_PREFIX: wpzundamochi_
https-portal:
image: steveltn/https-portal:1
ports:
- "192.168.19.19:80:80"
- "192.168.19.19:443:443"
restart: always
environment:
DOMAINS: 'www.zundamon-kawaii.com -> http://tsumugi-wordpress:80, blog.zundamon.co.jp -> http://zundamon-wordpress:80, www.zundamon.co.jp -> http://zundamon-wordpress:80, zundamon.co.jp -> http://zundamon-wordpress:80'
CLIENT_MAX_BODY_SIZE: 500M
STAGE: 'production' # Don't use production until staging works
# FORCE_RENEW: 'true'
volumes:
- https-portal-data:/var/lib/https-portal
volumes:
tsumugi-mariadb_data: {}
tsumugi-wordpress_data: {}
tsumugi-wordpress_php: {}
zundamon-mariadb_data: {}
zundamon-wordpress_data: {}
zundamon-wordpress_php : {}
https-portal-data: {}
413 Request entity too large
CLIENT_MAX_BODY_SIZE: 500M
附帶一提我不小心在 500M 後面加上分號變成 \CLIENT\_MAX\_BODY\_SIZE: 500M;\ 結果容器還是運行,但是顯然網站沒有回應。
查詢 https-portal 的 error.log 會出現以下特徵錯誤訊息,我的 Volume 配置是位處 dd87****87b 資料夾
2024/07/19 13:52:01 [emerg] 59#59: unexpected ";" in /etc/nginx/nginx.conf:56
sudo dolphin /var/lib/docker/volumes/yourstack-zundamon-wordpress_php/_data/conf.d 新增 uploads.ini 撰寫內容如下file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600
#!/bin/bash
# 定義變量
NFS_SERVER="192.168.x.x" #目的地 Hostname
NFS_PATH="/volume1/Backup-NFS" #目的地目錄
LOCAL_PATHS=(
"/var/lib/docker/volumes/yourblog_mariadb_data/_data"
"/var/lib/docker/volumes/yourblog_wordpress_data/_data"
#...自己新增與調整,字串結尾不需要逗號
)
MOUNT_POINT="/mnt/backup_nfs"
DATE_NOW=$(date +'%Y%m%d%H%M%S')
BACKUP_FILE="$MOUNT_POINT/web/websiteBackup_$DATE_NOW.tar.gz"
# 創建掛載點
mkdir -p $MOUNT_POINT
# 檢查 NFS 是否已經掛載
mountpoint -q $MOUNT_POINT
if [ $? -ne 0 ]; then
echo "掛載 NFS 共享目錄..."
mount -t nfs $NFS_SERVER:$NFS_PATH $MOUNT_POINT
if [ $? -ne 0 ]; then
echo "掛載 NFS 共享目錄失敗"
exit 1
fi
fi
# 壓縮並備份數據
tar -czf $BACKUP_FILE -C / ${LOCAL_PATHS[@]}
# 刪除多餘的備份
find $MOUNT_POINT -name "websiteBackup_*.tar.gz" -type f -print | while read FILE; do
FILE_DATE=$(basename $FILE | sed 's/websiteBackup_\(.*\)\.tar\.gz/\1/')
FILE_EPOCH=$(date -d "${FILE_DATE:0:8}" +%s)
NOW_EPOCH=$(date +%s)
AGE=$(( (NOW_EPOCH - FILE_EPOCH) / 86400 ))
if [ $AGE -le 7 ]; then
# 保留7天內的每日一份
continue
elif [ $AGE -le 30 ]; then
# 保留一個月內的每週一份
FILE_DAY=$(date -d "${FILE_DATE:0:8}" +%u)
if [ $FILE_DAY -eq 1 ]; then
continue
fi
elif [ $AGE -le 365 ]; then
# 保留一年內的每月一份
FILE_DAY=$(date -d "${FILE_DATE:0:8}" +%d)
if [ $FILE_DAY -eq 1 ]; then
continue
fi
elif [ $AGE -gt 365 ]; then
# 保留每年的第一天
FILE_MONTH_DAY=$(date -d "${FILE_DATE:0:8}" +%m%d)
if [ $FILE_MONTH_DAY -eq "0101" ]; then
continue
fi
fi
# 刪除不符合保留規則的文件
rm -f $FILE
done
crontab -e 搭配 micro 編輯器
當您在嘗試切換至 Steam Deck 的桌面模式時遇到黑畫面,這可能會讓人感到沮喪。然而,有一個簡單的解決方案可以幫助解決這個問題。以下是解決問題的逐步指南:
切換帳號:
Home/.local/share/kscreen 和 Home/.local/share/kscreen/outputs 的所有檔案(不包括資料夾)。對於已安裝 Decky 擴充套件框架的用戶:
sudo -i 登入 root,然後執行以下命令:
cd /home/deck/.local/share/kscreen
rm *
cd /home/deck/.local/share/kscreen/outputs
rm *
exit
fix.sh 的腳本檔案,包含上述命令並將其存放在 /home/deck/。記得使用命令 sudo chmod +x /home/deck/fix.sh 使腳本可執行。按照這些步驟操作,您應該能夠克服 Steam Deck 上的黑畫面問題,享受無縫的遊戲體驗。
這篇文章將介紹如何在 Windows 11 上讓 PowerShell 腳本(.ps1 檔案)雙擊執行。以下是操作過程:
1. 下載並解壓縮 SetUserFTA 工具:https://kolbi.cz/SetUserFTA.zip
2. 以管理員身份打開 CMD,執行以下指令(使用 Windows PowerShell):
ftype Microsoft.PowerShellScript.1="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -ExecutionPolicy Bypass -f "%1"
3. 使用 SetUserFTA 工具,給予參數執行:
SetUserFTA.exe .ps1 Microsoft.PowerShellScript.1
若選擇使用 PowerShell 7,將第二步驟指令替換為:
ftype Microsoft.PowerShellScript.1="C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -ExecutionPolicy Bypass -f "%1"
完成上述操作後,即可在 Windows 11 上雙擊 .ps1 檔案進行執行。
參考資料:
https://www.elevenforum.com/t/run-ps1-files-double-click-on-windows-11.2433/