Bladeren bron

上传米尔电子local-startup.service服务脚本

niujiuru 2 dagen geleden
bovenliggende
commit
2cc6e2308d

+ 24 - 0
myir-mkupdate-sdcard/local-startup.service/create-ftp-user.sh

@@ -0,0 +1,24 @@
+#!/bin/sh
+# create a dedicated FTP user for vsftpd service
+# 2026-05-08 10:25 created by niujiuru
+
+create_ftpuser_if_not_exists() {
+  FTP_USER="$1"
+  FTP_HOME="$2"
+  PASSWORD="$3"
+
+  if ! /usr/bin/id "$FTP_USER" >/dev/null 2>&1; then
+    /usr/sbin/useradd -m -d "$FTP_HOME" "$FTP_USER"
+    if [ $? -eq 0 ]; then
+      echo "$FTP_USER:$PASSWORD" | /usr/sbin/chpasswd
+    fi
+  fi
+
+  /bin/mkdir -p "$FTP_HOME"
+
+  if /usr/bin/id "$FTP_USER" >/dev/null 2>&1; then
+    /bin/chown "$FTP_USER:$FTP_USER" "$FTP_HOME"
+  fi
+}
+
+create_ftpuser_if_not_exists ftpuser /home/ftpuser ftpuser5678

+ 32 - 0
myir-mkupdate-sdcard/local-startup.service/startup.sh

@@ -0,0 +1,32 @@
+#!/bin/sh
+# runs on system startup
+# 2026-05-08 08:50 created by niujiuru
+
+# 设置系统主频
+[ -w /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && \
+  echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+
+[ -w /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed ] && \
+  echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
+
+# usbfs:内存值
+[ -w /sys/module/usbcore/parameters/usbfs_memory_mb ] && \
+  echo 500 > /sys/module/usbcore/parameters/usbfs_memory_mb
+
+# 拉起eth0网卡
+for i in 1 2 3 4 5; do
+  [ -d /sys/class/net/eth0 ] && /sbin/ip link set eth0 up && break
+  sleep 1
+done
+
+# FTP:创建用户
+[ -x /opt/yfkj/local-startup.service/create-ftp-user.sh ] && /opt/yfkj/local-startup.service/create-ftp-user.sh
+
+# 关闭无用服务
+systemctl stop rpcbind.socket
+systemctl stop rpcbind
+systemctl stop check_upgrade
+
+systemctl disable rpcbind.socket
+systemctl disable rpcbind
+systemctl disable check_upgrade