Tiny Core Extensions > Extension requests

firewalld Update

(1/4) > >>

Sashank999:
Hello.

Can the team please update firewalld for TCL v15.x x86_64 ?

Thank you.

Juanito:
I’ll take a look in 4-5 days time.

CentralWare:
@juanito: Here's your 12.x build updated to current
I've never played with firewall(d) so I was curious of what lies beneath.
It can probably be reduced further (I don't know what's essential vs. extra) so I leave it for your capable hands!
You'll probably want to update .info as well; I don't have the environment to test at this moment.

$EXTS tested under 14.x64

--- Code: ---#!/bin/sh

APPNAME="firewalld"
VERSION="2.3.0"

EXTS="wget compiletc iptables-dev nftables-dev ebtables ipset-dev intltool python3.9 glib2-dev autoconf automake"

CUR=$(pwd); clear
. /etc/init.d/tc-functions
echo "${CYAN}Loading Support Extensions${NORMAL}"
tce-load -w ${EXTS} >/dev/null 2>&1 || exit 1
tce-load -i ${EXTS} >/dev/null 2>&1 || exit 1

cat /proc/cpuinfo | grep "processor" | awk -F ":" '{print $2}' > /tmp/nproc
while read ninfo
do
    [ ! "${ninfo}" == "" ] && nproc=$ninfo
done < /tmp/nproc
#echo "$(expr $nproc + 1)"

[ ! -f ${APPNAME}-${VERSION}.tar.bz2 ] && \
    echo "${CYAN}Downloading Source Code${NORMAL}" && \
    wget -q --no-check-certificate https://github.com/${APPNAME}/${APPNAME}/releases/download/v${VERSION}/${APPNAME}-${VERSION}.tar.bz2
[ ! -d ${APPNAME}-${VERSION} ] && \
    echo "${CYAN}Extracting Source Code${NORMAL}" && \
    tar -jxf ${APPNAME}-${VERSION}.tar.bz2

[ ! -d ${APPNAME}-${VERSION} ] && echo "${RED}SOURCE DIRECTORY NOT FOUND${NORMAL}" && exit 1

cd ${APPNAME}-${VERSION}
if [ ! -f ./.configured ]; then
    echo "${CYAN}Configuring Source Code${NORMAL}"
    CC="gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe" \
    CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions -fno-rtti" \
    ./configure --prefix=/usr/local --localstatedir=/var --disable-docs > $CUR/_config.log 2>&1 || exit
    touch ./.configured
fi

mkdir -p /tmp/build /tmp/builder
sudo rm /tmp/build -fR
sudo rm /tmp/builder -fR

echo "${CYAN}Compiling Source Code${NORMAL}"
make -j${nproc} >$CUR/_compile.log 2>&1 || exit 1

echo "${CYAN}Installing Compiled Package${NORMAL}"
make DESTDIR=/tmp/build/${APPNAME} install >$CUR/_install.log 2>&1 || exit 1

cd /tmp/build/${APPNAME}
find . -type f > $CUR/${APPNAME}.tcz.list
sed -i 's/.\/usr/\/usr/g' $CUR/${APPNAME}.tcz.list

echo "${CYAN}Preparing Package${NORMAL}"
sed -i 's/datadir = None/datadir=\/usr\/local\/share\/firewalld/g' /tmp/build/${APPNAME}/usr/local/bin/firewall-config

cd /tmp/build/${APPNAME}/usr/local
find . -type f -exec strip -s {} \; >/dev/null 2>&1

cd /tmp/build
mksquashfs ${APPNAME} $CUR/${APPNAME}.tcz >$CUR/_squash.log 2>&1 || exit 1
sudo rm ${APPNAME} -fR

cd $CUR
md5sum ${APPNAME}.tcz > ${APPNAME}.tcz.md5.txt

SIZE=$(ls -la ${APPNAME}.tcz | awk '{print $5}')
[ $SIZE -gt 1023 ] && SIZE=$(expr $SIZE / 1024) && SFX="KB"
[ $SIZE -gt 1023 ] && SIZE=$(expr $SIZE / 1024) && SFX="MB"
[ $SIZE -gt 1023 ] && SIZE=$(expr $SIZE / 1024) && SFX="GB"

echo "Title:          ${APPNAME}.tcz" > $CUR/${APPNAME}.tcz.info
echo "Description:    dynamically managed firewall" >> $CUR/${APPNAME}.tcz.info
echo "Version:        ${VERSION}" >> $CUR/${APPNAME}.tcz.info
echo "Author:         see list of sites below" >> $CUR/${APPNAME}.tcz.info
echo "Original-site:  see list of sites below" >> $CUR/${APPNAME}.tcz.info
echo "Copying-policy: see list of sites below" >> $CUR/${APPNAME}.tcz.info
echo "Size:           ${SIZE}${SFX}" >> $CUR/${APPNAME}.tcz.info
echo "Extension_by:   juanito" >> $CUR/${APPNAME}.tcz.info
echo "Tags:           firewall python python3.9" >> $CUR/${APPNAME}.tcz.info
echo "Comments:       dynamically managed firewall with support for network or firewall" >> $CUR/${APPNAME}.tcz.info
echo "                zones to define the trust level of network connections or interfaces" >> $CUR/${APPNAME}.tcz.info
echo "                ----------" >> $CUR/${APPNAME}.tcz.info
echo "                requires dbus daemon to be running" >> $CUR/${APPNAME}.tcz.info
echo "                \$ sudo firewalld" >> $CUR/${APPNAME}.tcz.info
echo "                ----------" >> $CUR/${APPNAME}.tcz.info
echo "                This extension contains:" >> $CUR/${APPNAME}.tcz.info
echo "                ${APPNAME}-${VERSION} - https://github.com/firewalld/firewalld/releases/download/v${VERSION}/${APPNAME}-${VERSION}.bz2" >> $CUR/${APPNAME}.tcz.info
echo "                ----------" >> $CUR/${APPNAME}.tcz.info
echo "Change-log:     first version" >> $CUR/${APPNAME}.tcz.info
echo "Current:        2025/01/23" >> $CUR/${APPNAME}.tcz.info
[code]

--- End code ---

Rich:
Hi CentralWare
Just an observation, because I'm not clear on what the exact intent was:

--- Quote from: CentralWare on January 23, 2025, 02:08:17 AM ---
--- Code: ---cat /proc/cpuinfo | grep "processor" | awk -F ":" '{print $2}' > /tmp/nproc
while read ninfo
do
    [ ! "${ninfo}" == "" ] && nproc=$ninfo
done < /tmp/nproc
#echo "$(expr $nproc + 1)"
--- End code ---

--- End quote ---

On my system, the first command produces this:

--- Code: ---tc@E310:~/editor$ cat /proc/cpuinfo | grep "processor" | awk -F ":" '{print $2}'
 0
 1
--- End code ---

If you just wanted the last result from grep:

--- Code: ---tc@E310:~/editor$ cat /proc/cpuinfo | grep "processor" | awk -F ":" '{print $2}' | tail -n1
 1
--- End code ---

If you just wanted the number of results from grep:

--- Code: ---tc@E310:~/editor$ cat /proc/cpuinfo | grep "processor" | awk -F ":" '{print $2}' | wc -l
2
--- End code ---

Just my 2 cents.

CentralWare:
Sorry, that's a cut/paste/patch from a larger function.
There's a problem using cpuinfo for determining the number of processors.

Imagine the following:

--- Code: ---processor          : 0
...
model name         : AMD Ryzen 7 3800X 8-core processor
...

--- End code ---
model name makes tail return invalid information.

If there were such thing as "proper" way, I'd suspect awk'ing the second field of -F: and grep'ing numeric only - which is not "fool proof" but may serve most instances

--- Code: ---cat /proc/cpuinfo | grep processor | awk -F: '{print $2}' | grep -Eo '[0-9]{0,9}' | tail -n 1
# and then value+1

--- End code ---
...but the next guy will say they can do it better, so, se-lä-vē!
Or is it Say La Vee!?  Everyone's got their own!                                                 (C'est la vie)

Intention: To manually count "Processor : #" to get the largest value, add one and use that count for make -j${VALUE} when nproc() is unavailable (and not having to install an extension just to have nproc() basically do the same thing in the end.)

Additionally: I don't own "every" processor ever made, thus I cannot ensure grep -Eo wouldn't fail under certain conditions, too.

Navigation

[0] Message Index

[#] Next page

Go to full version