You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublinux-init/ublinux/rc.halt.pre/75-chmod

32 lines
1.4 KiB

#!/usr/bin/bash
#
# Author: Dmitry Razumov <asmeron@ublinux.com>
# Copyright (c) 2021-2025 UBLinux <support@ublinux.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
ENABLED=yes
[[ ${ENABLED} == "yes" ]] || { return 0 2>/dev/null && return 0 || exit 0; }
chmod_ublinux() {
local PATH_UBLINUX=$1
if [[ -w ${PATH_UBLINUX} ]]; then
chown -fR root:root "${PATH_UBLINUX}"/{base,machines,modules,optional,upgrade,install} 2>/dev/null
chown -f root:root "${PATH_UBLINUX}"/{cache,changes,rootcopy,homes} 2>/dev/null
chmod -f 0750 "${PATH_UBLINUX}"/{base,machines,modules,machines/dynamic,machines/static,optional,upgrade,install} 2>/dev/null
chmod -f 0755 "${PATH_UBLINUX}"/{cache,changes,rootcopy,homes} 2>/dev/null
find "${PATH_UBLINUX}"/{base,machines,modules,optional,upgrade,install}/ -type f -exec chmod -f 0640 {} + 2>/dev/null
chmod -f 0644 "${PATH_UBLINUX}"/LICENSE*; chown -f root:root "${PATH_UBLINUX}"/LICENSE*
chmod -f 0640 "${PATH_UBLINUX}"/VERSION*; chown -f root:root "${PATH_UBLINUX}"/VERSION*
chmod -f 0640 "${PATH_UBLINUX}"/boot*; chown -f root:root "${PATH_UBLINUX}"/boot*
chmod -f 0640 "${PATH_UBLINUX}"/ublinux*; chown -f root:root "${PATH_UBLINUX}"/ublinux*
chmod -f 0640 "${PATH_UBLINUX}"/vmlinuz*; chown -f root:root "${PATH_UBLINUX}"/vmlinuz*
fi
}
for ITEM_LAYER in $(find /memory/layer-base/* -maxdepth 0); do
chmod_ublinux ${ITEM_LAYER} 2>/dev/null
done