single threaded encfs and cleanup

This commit is contained in:
SkyperTHC 2022-11-16 10:42:27 +00:00
parent 76a262970a
commit 82023c1096
No known key found for this signature in database
GPG Key ID: A9BD386DF9113CD6
6 changed files with 15 additions and 10 deletions

@ -1,4 +1,4 @@
VER := 0.3.6
VER := 0.3.7a
all:
make -C guest

@ -83,7 +83,8 @@ encfs_mount()
LOG "${name}" "Mounting ${info}"
# echo "$s" | bash -c "exec -a '[encfs-${name:-BAD}]' encfs --standard --public -o nonempty -S \"${rawdir}\" \"${secdir}\" -- -o fsname=/dev/sec-\"${name}\" -o \"${opts}\"" >/dev/null
# --nocache -> Blindly hoping that encfs consumes less memory?!
echo "$s" | bash -c "exec -a '[encfs-${name:-BAD}]' encfs --nocache --standard --public -o nonempty -S \"${rawdir}\" \"${secdir}\" -- -o \"${opts}\"" >/dev/null
# -s single thread. Seems to give better I/O performance and uses less memory (!)
echo "$s" | bash -c "exec -a '[encfs-${name:-BAD}]' encfs -s --nocache --standard --public -o nonempty -S \"${rawdir}\" \"${secdir}\" -- -o \"${opts}\"" >/dev/null
ret=$?
[[ $ret -eq 0 ]] && return 0
@ -110,6 +111,8 @@ encfs_mount_server()
encfs_mount "${name}" "${secret}" "${secdir}" "${rawdir}" "noexec,noatime" || ERREXIT 254 "EncFS ${name}-root failed."
touch "${secdir}/.IS-ENCRYPTED"
[[ ! -d "${secdir}/${name}" ]] && mkdir "${secdir}/${name}"
# redis-cli -h sf-redis SET "encfs-ts-${name}" "$(date +%s)"
}

@ -45,6 +45,7 @@ RUN apt-get update -y \
bison \
build-essential \
byacc \
dtach \
flex \
g++ \
gawk \

@ -7,8 +7,9 @@ IS_APT=1
install_sw()
{
command -v docker >/dev/null && return
# Docker
docker ps &>/dev/null || bash -c "$(curl -fsSL https://get.docker.com)" || ERREXIT 255
bash -c "$(curl -fsSL https://get.docker.com)" || ERREXIT 255
# Software
if [[ -z $SF_NO_INTERNET ]]; then

@ -153,6 +153,7 @@ init_config_run()
mergedir "config/etc/nginx"
mergedir "config/etc/redis"
mergedir "config/etc/hosts"
mergedir "config/etc/resolv.conf"
[[ ! -f "${SF_DATADIR}/share/GeoLite2-City.mmdb" ]] && curl 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=zNACjsJrHnGPBxgI&suffix=tar.gz' | tar xfvz - --strip-components=1 --no-anchored -C "${SF_DATADIR}/share/" 'GeoLite2-City.mmdb'
[[ ! -f "${SF_DATADIR}/share/tor-exit-nodes.txt" ]] && curl 'https://www.dan.me.uk/torlist/?exit' >"${SF_DATADIR}/share/tor-exit-nodes.txt"
@ -173,6 +174,7 @@ init_config_run()
modprobe bfq || {
"${PKG_INSTALL[@]}" linux-modules-extra-aws || ERREXIT 254
modprobe bfq || ERREXIT 255
}
}
docker_fixdir()
@ -211,8 +213,6 @@ xinstall()
docker_config()
{
local ncpu
xinstall daemon.json /etc/docker
xinstall sf.slice /etc/systemd/system
xinstall sf_guest.slice /etc/systemd/system
@ -303,9 +303,9 @@ if [[ -e "${ENV}" ]]; then
IS_USING_EXISTING_ENV_FILE=1
CONFLICT+=("${ENV}");
else
cp "${SFI_SRCDIR}/provision/env.example" "${ENV}" &&
sed "s/^SF_BASEDIR.*/SF_BASEDIR=${SF_BASEDIR//\//\\/}/" -i "${ENV}" &&
sed "s/.*SF_SHMDIR.*/SF_SHMDIR=${SF_SHMDIR//\//\\/}/" -i "${ENV}" &&
cp "${SFI_SRCDIR}/provision/env.example" "${ENV}" || ERREXIT 122 failed
sed "s/^SF_BASEDIR.*/SF_BASEDIR=${SF_BASEDIR//\//\\/}/" -i "${ENV}" || ERREXIT 132 failed
sed "s/.*SF_SHMDIR.*/SF_SHMDIR=${SF_SHMDIR//\//\\/}/" -i "${ENV}" || ERREXIT 133 failed
sed "s/.*SF_FQDN.*/SF_FQDN=${SF_FQDN//\//\\/}/" -i "${ENV}" || ERREXIT 120 failed
[[ -n $SF_SSH_PORT ]] && { sed "s/.*SF_SSH_PORT.*/SF_SSH_PORT=${SF_SSH_PORT}/" -i "${ENV}" || ERREXIT 121 failed; }
[[ -n $SF_NORDVPN_PRIVATE_KEY ]] && { sed "s/.*SF_NORDVPN_PRIVATE_KEY.*/SF_NORDVPN_PRIVATE_KEY=${SF_NORDVPN_PRIVATE_KEY//\//\\/}/" -i "${ENV}" || ERREXIT 121 failed; }
@ -354,7 +354,7 @@ INFO "To Start : ${CDY}SF_SEED='$SF_SEED' sfbin/sf up --force-recreat
INFO "SSH : ${CDC}ssh ${PORTSTR}${SF_USER:-root}@${SF_FQDN:-UNKNOWN}${CN}"
INFO "SSH (gsocket) : ${CDC}gsocket -s ${GS_SECRET} ssh ${SF_USER:-root}@${SF_FQDN%.*}.gsocket${CN}"
[[ -n $CONFLICT ]] && {
[[ ${#CONFLICT[@]} -gt 0 ]] && {
WARN 7 "Not updating these:"
for x in "${CONFLICT[@]}"; do
INFO "${x}"

@ -47,7 +47,7 @@ echo -e "${CDC}lgwall <LID> <message>${CN} # eg \`lgwall lg-NGVlMTNmMj "'"G
# [<REGEX>] <stop>
plgtop()
{
systemd-cgls -l | while read x; do
systemd-cgls -l -u docker_limit.slice | while read x; do
[[ $x == *" [init-"* ]] && { lid="${x#* \[init-}"; lid="${lid%%-*}"; }
[[ ! $x =~ ${1:?} ]] && continue
[[ ${#lid} -ne 10 ]] && continue