2024年3月6日 星期三

samba-tool:WARNING: Using password on command line is insecure. Please install the setproctitle python module.

WARNING: Using password on command line is insecure. Please install the setproctitle python module.

mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.bk
pip install setproctitle --root-user-action=ignore

Python:WARNING: Running pip as the 'root' user

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

pip install --root-user-action=ignore

email 通知硬碟狀況

#!/bin/bash
# 2024-04-23
# busybox sendmail
# https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/

mta="busybox sendmail "
S=email.server
f="from<user@email.loc>"
t="to<user@email.loc>"

ema(){ local t;t=${1##*\<};t=${t%%\>};echo $t; }
ips(){ ip a|grep "inet "|grep -v 127.0.0.1|awk '{print $2}'; }
hdds(){ lsblk -l |grep " disk "|awk '{print $1}'; }

s="$(date) <`ips` $(hostname)>"

cat <<EOF | ${mta} -f $(ema ${f}) -t "$(ema ${t})" -S ${S}
Subject: ${s}
CC:
To: ${t}
From: ${f}

$(date)
Disk Usage ====================================================
$(df -h 2>&1)

MD stat =======================================================
$(cat /proc/mdstat)

ZFS stat ======================================================
$(zpool status 2>&1)

HDD Smart stat ================================================
`for i in $(hdds);do echo /dev/${i} @@@@@@@@@;smartctl -H /dev/${i} 2>&1;done`

EOF

XRDP管理筆記

查詢xrdp 相關process
#!/bin/bash
for i in $(ps --no-header -o pid -C xrdp-sesman);do
ps -o ppid,pid,uid,user:16,cmd --ppid ${i}
done

相關指令
xrdp-sesadmin -u=root -s=localhost -c=list

相關檔案
/etc/xrdp/sesman.ini    #設定 ListenPort,ReconnectScript,MaxSessions
/etc/xrdp/xrdp.ini

time chrony 設定 ntp server

1.編輯 /etc/chrony/chrony.conf 
加入 server a.b.c.d iburst

2.重啟服務
systemctl restart chrony

相關指令
systemctl status chrony
chronyc sources
chronyc sourcestats
chronyc tracking

自定 systemd-timesyncd.service NTP server

1.編輯 /etc/systemd/timesyncd.conf
[Time]
NTP=a.b.c.d

2.重啟服務
systemctl restart systemd-timesyncd.service

3.相關指令
systemctl status systemd-timesyncd.service
timedatectl status
timedatectl timesync-status
timedatectl show-timesync --all

journalctl -u systemd-timesyncd --no-hostname --since "1 day ago"