Skip to content

bash format added in make format #1329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,65 @@ ROOT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
source ./kmesh_compile_env_pre.sh

function install() {
mkdir -p /etc/kmesh
chmod 700 /etc/kmesh
mkdir -p /etc/kmesh
chmod 700 /etc/kmesh

cp $ROOT_DIR/build/kmesh-start-pre.sh /usr/bin
chmod 500 /usr/bin/kmesh-start-pre.sh
cp $ROOT_DIR/build/kmesh-stop-post.sh /usr/bin
chmod 500 /usr/bin/kmesh-stop-post.sh
cp $ROOT_DIR/build/kmesh-start-pre.sh /usr/bin
chmod 500 /usr/bin/kmesh-start-pre.sh
cp $ROOT_DIR/build/kmesh-stop-post.sh /usr/bin
chmod 500 /usr/bin/kmesh-stop-post.sh

mkdir -p /etc/oncn-mda
chmod 700 /etc/oncn-mda
cp $ROOT_DIR/oncn-mda/etc/oncn-mda.conf /etc/oncn-mda/
chmod 600 /etc/oncn-mda/oncn-mda.conf
mkdir -p /etc/oncn-mda
chmod 700 /etc/oncn-mda
cp $ROOT_DIR/oncn-mda/etc/oncn-mda.conf /etc/oncn-mda/
chmod 600 /etc/oncn-mda/oncn-mda.conf
}

function uninstall() {
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
rm -rf /etc/oncn-mda
rm -rf /usr/share/oncn-mda
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
rm -rf /etc/oncn-mda
rm -rf /usr/share/oncn-mda
}

function clean() {
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
}

set_enhanced_kernel_env

if [ "$1" == "-h" -o "$1" == "--help" ]; then
echo build.sh -h/--help : Help.
echo build.sh -b/--build: Build Kmesh.
echo build.sh -i/--install: Install Kmesh.
echo build.sh -c/--clean: Clean the built binary.
echo build.sh -u/--uninstall: Uninstall Kmesh.
exit
if [ "$1" == "-h" -o "$1" == "--help" ]; then
echo build.sh -h/--help : Help.
echo build.sh -b/--build: Build Kmesh.
echo build.sh -i/--install: Install Kmesh.
echo build.sh -c/--clean: Clean the built binary.
echo build.sh -u/--uninstall: Uninstall Kmesh.
exit
fi

if [ -z "$1" -o "$1" == "-b" -o "$1" == "--build" ]; then
prepare
make
exit
if [ -z "$1" -o "$1" == "-b" -o "$1" == "--build" ]; then
prepare
make
exit
fi

if [ "$1" == "-i" -o "$1" == "--install" ]; then
make install
install
exit
if [ "$1" == "-i" -o "$1" == "--install" ]; then
make install
install
exit
fi

if [ "$1" == "-u" -o "$1" == "--uninstall" ]; then
make uninstall
uninstall
exit
if [ "$1" == "-u" -o "$1" == "--uninstall" ]; then
make uninstall
uninstall
exit
fi

if [ "$1" == "-c" -o "$1" == "--clean" ]; then
make clean
clean
exit
if [ "$1" == "-c" -o "$1" == "--clean" ]; then
make clean
clean
exit
fi
36 changes: 18 additions & 18 deletions build/docker/start_kmesh.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/sh

# docker image compile online, if not compile online, the following lines also have no effect
# docker image compile online, if not compile online, the following lines also have no effect

lsmod | grep kmesh > /dev/null
lsmod | grep kmesh >/dev/null
if [ $? -ne 0 ] && [ -f kmesh.ko ]; then
cp kmesh.ko /lib/modules/$(uname -r)
depmod -a
modprobe kmesh
depmod -a
modprobe kmesh
fi

mount | grep /mnt/kmesh_cgroup2
if [ $? -ne 0 ]; then
mkdir -p /mnt/kmesh_cgroup2
mount -t cgroup2 none /mnt/kmesh_cgroup2/
if [ $? -ne 0 ]; then
echo "mount cgroup2 failed"
fi
mkdir -p /mnt/kmesh_cgroup2
mount -t cgroup2 none /mnt/kmesh_cgroup2/
if [ $? -ne 0 ]; then
echo "mount cgroup2 failed"
fi
fi

mount | grep "type bpf"
Expand All @@ -31,24 +31,24 @@ pid=$!

# pass SIGTERM to kmesh process
function stop_kmesh() {
echo "received SIGTERM, stopping kmesh"
kill $pid
echo "received SIGTERM, stopping kmesh"
kill $pid
}

function cleanup(){
lsmod | grep kmesh > /dev/null
if [ $? == 0 ]; then
rmmod kmesh
fi
function cleanup() {
lsmod | grep kmesh >/dev/null
if [ $? == 0 ]; then
rmmod kmesh
fi

echo "kmesh exit"
echo "kmesh exit"
}

trap 'stop_kmesh' SIGTERM

# wait for kmesh process to exit, cannot use wait $pid here, because the script received SIGTERM, wait will return immediately
while kill -0 $pid 2>/dev/null; do
sleep 1
sleep 1
done

kmesh-daemon uninstall $@
Expand Down
2 changes: 1 addition & 1 deletion build/kmesh-start-pre.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
lsmod | grep kmesh > /dev/null
lsmod | grep kmesh >/dev/null
if [ $? == 0 ]; then
rmmod kmesh
depmod -a
Expand Down
4 changes: 2 additions & 2 deletions build/kmesh-stop-post.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
lsmod | grep kmesh > /dev/null
lsmod | grep kmesh >/dev/null
if [ $? == 0 ]; then
rmmod kmesh
fi

umount -t cgroup2 /mnt/kmesh_cgroup2/
rm -rf /mnt/kmesh_cgroup2 > /dev/null
rm -rf /mnt/kmesh_cgroup2 >/dev/null
rm -rf /sys/fs/bpf/bpf_kmesh
Loading
Loading