#!/usr/bin/env ash # # Copyright (C) 2023 AuxXxilium and Ing # # This is free software, licensed under the MIT License. # See /LICENSE for more information. # if [ "${1}" = "late" ]; then echo "Installing addon setrootpw - ${1}" mkdir -p "/tmpRoot/usr/arc/addons/" cp -pf "${0}" "/tmpRoot/usr/arc/addons/" mkdir -p /tmpRoot/usr/lib/openssh cp -pf /usr/lib/openssh/sftp-server /tmpRoot/usr/lib/openssh/sftp-server [ ! -f "/tmpRoot/usr/lib/libcrypto.so.3" ] && cp -pf /usr/lib/libcrypto.so.3 /tmpRoot/usr/lib/libcrypto.so.3 FILE="/tmpRoot/etc/ssh/sshd_config" [ ! -f "${FILE}.bak" ] && cp -f "${FILE}" "${FILE}.bak" SED_PATH='/tmpRoot/usr/bin/sed' cp -f "${FILE}.bak" "${FILE}" ${SED_PATH} -i 's|^.*PermitRootLogin.*$|PermitRootLogin yes|' ${FILE} ${SED_PATH} -i 's|^Subsystem.*$|Subsystem sftp /usr/lib/openssh/sftp-server|' ${FILE} if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then echo "copy esynoscheduler.db" mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler cp -pf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db fi echo "insert setrootpw task to esynoscheduler.db" export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib if echo "SELECT * FROM task;" | /tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db | grep -q "SetRootPw||bootup||1|0|0|0||0|"; then echo "SetRootPw task already exists and it is enabled" else /tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <