Skip to content

Commit

Permalink
Update for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
krtab authored and emilienlemaire committed Oct 1, 2024
1 parent bd2e62c commit bd62281
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 37 deletions.
64 changes: 30 additions & 34 deletions scripts/package-superbol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ fi


export SUPERBOL_PACKAGING=1
INSTALLDIR=$(readlink -f "${TARGETDIR:-/home/bas/superbol}")
INSTALLDIR="/home/bas/superbol"
BUILDDIR=$(readlink -f "${BUILDDIR:-$(pwd)/tmp-builddir}")
SWITCHNAME="${SWITCHNAME:-for-padbol}"
TARGETDIR=$(readlink -f "${TARGETDIR:-INSTALL_DIR}")

echo "Packaging SuperBOL into ${TARGETDIR}"

export LD_LIBRARY_PATH="${TARGETDIR}/lib:${TARGETDIR}/lib64"
export LIBRARY_PATH="${TARGETDIR}/lib:${TARGETDIR}/lib64"
export LD_LIBRARY_PATH="${TARGETDIR}/${INSTALLDIR}/lib:${TARGETDIR}/${INSTALLDIR}/lib64"
export LIBRARY_PATH="${TARGETDIR}/${INSTALLDIR}/lib:${TARGETDIR}/${INSTALLDIR}/lib64"
export CFLAGS="-static-libgcc"
export CXXFLAGS="-static-libgcc -static-libstdc++"

DATE=$(date +%Y%m%d%H%M)

Expand Down Expand Up @@ -109,34 +111,34 @@ fi

if [ ! -e ${TARGETDIR}/commits/gixsql-${GIXSQL_COMMIT} ]; then

export CMAKE_PREFIX_PATH=$TARGETDIR
export CMAKE_MODULE_PATH=$TARGETDIR/lib
export PKG_CONFIG_PATH=${TARGETDIR}/lib64/pkgconfig:${TARGETDIR}/lib/pkgconfig
export CMAKE_PREFIX_PATH=$TARGETDIR/$INSTALLDIR
export CMAKE_MODULE_PATH=${TARGETDIR}/${INSTALLDIR}/lib
export PKG_CONFIG_PATH=${TARGETDIR}/${INSTALLDIR}/lib64/pkgconfig:${TARGETDIR}/${INSTALLDIR}/lib/pkgconfig
export CMAKE_FIND_USE_CMAKE_SYSTEM_PATH=FALSE

cd fmt
if [ ! -e "_build/commits/${FMT_COMMIT}" ]; then
mkdir -p _build
cd _build
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGETDIR} -DBUILD_SHARED_LIBS=TRUE -DFMT_TEST=OFF ..
cmake -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR} -DBUILD_SHARED_LIBS=TRUE -DFMT_TEST=OFF ..
make -j
cd ..
fi
cd _build
make install
make DESTDIR=${TARGETDIR} install
rm -rf commits
mkdir commits
touch commits/${FMT_COMMIT}
cd ../..

export CXXFLAGS="$(pkg-config --cflags fmt)"
export CXXFLAGS="$(pkg-config --cflags fmt) $CXXFLAGS"
export LIBS="$(pkg-config --libs fmt) $LIBS"

cd spdlog
if [ ! -e "_build/commits/${SPDLOG_COMMIT}" ]; then
mkdir -p _build
cd _build
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGETDIR} \
cmake -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR} \
-DBUILD_SHARED_LIBS=TRUE \
-DSPDLOG_BUILD_EXAMPLE=NO \
-DSPDLOG_BUILD_TESTS=NO \
Expand All @@ -147,7 +149,7 @@ if [ ! -e ${TARGETDIR}/commits/gixsql-${GIXSQL_COMMIT} ]; then
cd ..
fi
cd _build
make install
make DESTDIR=${TARGETDIR} install
rm -rf commits
mkdir commits
touch commits/${SPDLOG_COMMIT}
Expand All @@ -160,10 +162,10 @@ if [ ! -e ${TARGETDIR}/commits/gixsql-${GIXSQL_COMMIT} ]; then
if [ ! -e "commits/${GIXSQL_COMMIT}" ]; then
touch extra_files.mk
autoreconf -i
./configure --prefix=${TARGETDIR}
./configure --prefix=${INSTALLDIR}
make -j
fi
make install
make DESTDIR=${TARGETDIR} install
mkdir -p commits
touch commits/${GIXSQL_COMMIT}
mkdir -p ${TARGETDIR}/commits/
Expand All @@ -176,34 +178,33 @@ if [ ! -e ${TARGETDIR}/commits/gnucobol-${GNUCOBOL_COMMIT} ]; then
cd visam-2.2
if [ ! -e _build/version/2.2 ]; then
echo "Not installed: building"
if [ -e Makefile ]; then
make distclean
fi
rm -rf _build
mkdir -p _build
cd _build
../configure --prefix=${TARGETDIR} --enable-vbisamdefault
../configure --prefix=${INSTALLDIR} --enable-vbisamdefault
make -j
cd ..
else
echo "Installed"
fi
cd _build
make install
ln -s ${TARGETDIR}/lib/libvisam.so ${TARGETDIR}/lib/libvbisam.so
ln -s ${TARGETDIR}/include/visam.h ${TARGETDIR}/include/vbisam.h
make DESTDIR=${TARGETDIR} install
ln -s ${TARGETDIR}/${INSTALLDIR}/lib/libvisam.so ${TARGETDIR}/${INSTALLDIR}/lib/libvbisam.so
ln -s ${TARGETDIR}/${INSTALLDIR}/include/visam.h ${TARGETDIR}/${INSTALLDIR}/include/vbisam.h
mkdir -p version
touch version/2.2
cd ../..
LD_LIBRARY_PATH=${TARGETDIR}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
LIBRARY_PATH=${LD_LIBRARY_PATH}
export LIBRARY_PATH
C_INCLUDE_PATH=${TARGETDIR}/include
C_INCLUDE_PATH=${TARGETDIR}/${INSTALLDIR}/include
export C_INCLUDE_PATH
cd gnucobol
if [ ! -e _build/commits/${GNUCOBOL_COMMIT} ]; then
mkdir -p _build
cd _build
../autogen.sh install
../configure --prefix=${TARGETDIR} --with-vbisam
../configure --prefix=${INSTALLDIR} --with-vbisam
make -j
rm -rf commits
mkdir commits
Expand All @@ -217,12 +218,6 @@ if [ ! -e ${TARGETDIR}/commits/gnucobol-${GNUCOBOL_COMMIT} ]; then
cd ../..
fi

LD_LIBRARY_PATH=${TARGETDIR}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH

LIBRARY_PATH=${LD_LIBRARY_PATH}
export LIBRARY_PATH

C_INCLUDE_PATH=${TARGETDIR}/include
export C_INCLUDE_PATH

Expand All @@ -240,11 +235,12 @@ if [ ! -e ${TARGETDIR}/commits/superbol-${SUPERBOL_COMMIT} ]; then
mkdir -p ${TARGETDIR}/bin/
mkdir -p ${TARGETDIR}/lib/

cp -f padbol ${TARGETDIR}/bin/superbol
find superkix/third-parties -name '*.so' -exec cp -f {} ${TARGETDIR}/lib \;
cp -f superkix/target/release/server ${TARGETDIR}/bin/superkix
cp -f superkix/target/release/libsuperkix.so ${TARGETDIR}/lib/
cp -f $(ldd ${TARGETDIR}/bin/superkix | awk '{ print $3 }' | grep -v ${TARGETDIR}) ${TARGETDIR}/lib/
cp -fv padbol ${TARGETDIR}/${INSTALLDIR}/bin/superbol
find superkix/third-parties -name '*.so' -exec cp -fv {} ${TARGETDIR}/${INSTALLDIR}/lib \;
cp -fv superkix/target/release/libsuperkix.so ${TARGETDIR}/${INSTALLDIR}/lib
cp -fv superkix/target/release/server ${TARGETDIR}/${INSTALLDIR}/bin/superkix
cp -fv $(ldd ${TARGETDIR}/${INSTALLDIR}/bin/superkix | awk '{ print $3 }' | grep -v ${TARGETDIR}) ${TARGETDIR}/${INSTALLDIR}/lib/
rm -f ${TARGETDIR}/${INSTALLDIR}/lib/libc.so.*
cd ..

touch ${TARGETDIR}/commits/superbol-${SUPERBOL_COMMIT}
Expand Down
9 changes: 9 additions & 0 deletions scripts/vm-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/usr/bin/bash

pwd

export LD_LIBRARY_PATH=/home/bas/superbol/lib:/usr/host/lib
export PATH=/home/bas/superbol/bin:${PATH}

if [ ! -e Makefile ]; then
cd ${APP_HOME}/cobol_repo
fi

./configure
make
make install
4 changes: 3 additions & 1 deletion scripts/vm-git-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mkdir -p $(dirname $LOG_FILE)


${APP_HOME}/scripts/vm-build.sh >> $LOG_FILE 2>&1
pkill -HUP superkix

# Fonction principale
while true; do
Expand All @@ -26,10 +27,11 @@ while true; do

# Recompiler et installer
echo "Running ./configure && make && make install" >> $LOG_FILE 2>&1
${APP_HOME}/scripts/vm-build.sh
${APP_HOME}/scripts/vm-build.sh >> $LOG_FILE 2>&1

if [ $? -eq 0 ]; then
echo "Build and installation successful." >> $LOG_FILE 2>&1
pkill -HUP superkix
else
echo "Build or installation failed." >> $LOG_FILE 2>&1
fi
Expand Down
23 changes: 23 additions & 0 deletions scripts/vm-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

# Install the latest release on the VM

INSTALLDIR=$(readlink -f "${INSTALLDIR:-${HOME}/superbol}")

mkdir -p tmp-install

mkdir -p ${INSTALLDIR}/bin
mkdir -p ${INSTALLDIR}/lib
mkdir -p ${INSTALLDIR}/include
mkdir -p ${INSTALLDIR}/share


tar -xvzf superbol-install.tar.gz -C tmp-install

cp -Rf tmp-install/target/home/* /home/

export PATH=${INSTALLDIR}/bin:${PATH}
export LD_LIBRARY_PATH=${INSTALLDIR}/lib:${LD_LIBRARY_PATH}
export C_INCLUDE_PATH=${INSTALLDIR}/include:${C_INCLUDE_PATH}
9 changes: 7 additions & 2 deletions scripts/vm-start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/bash

set -e

cat << EOM
.,,,,,,*
,,,,,,*****
Expand All @@ -18,7 +20,10 @@ cat << EOM
EOM


git clone $COB_GIT_REPO cobol_repo
./scripts/vm-install.sh
git clone $COB_GIT_REPO ${APP_HOME}/cobol_repo
export LD_LIBRARY_PATH=/home/bas/superbol/lib:/usr/host/lib
export PATH=/home/bas/superbol/bin:$PATH
${APP_HOME}/scripts/vm-git-check.sh &
env | sort
/home/bas/superbol/bin/server -v run -c $APP_HOME/cobol_repo/config.toml
/home/bas/superbol/bin/superkix -v run $APP_HOME/cobol_repo
Binary file added superbol-install.tar.gz
Binary file not shown.
51 changes: 51 additions & 0 deletions superkix-server/static/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Socket Address and Timestamps</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<p>Build log available <a href="/git_log">here</a></p>
<p>Last loaded config: {{ loaded_path }}</p>
<h1>Socket Address and Timestamps</h1>
<table>
<thead>
<tr>
<th>Socket Address</th>
<th>Timestamp (UTC)</th>
</tr>
</thead>
<tbody>
{# Iterate over the hashmap #}
{% for addr, timestamp in connections %}
<tr>
<td>{{ addr }}</td>
<td>{{ timestamp }}</td>
</tr>
{% else %}
<tr>
<td colspan="2">No data available</td>
</tr>
{% endfor %}
</tbody>
</table>

</body>
</html>
34 changes: 34 additions & 0 deletions superkix-server/static/templates/log.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git log</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1 {
color: #333;
}
.console {
background-color: #1e1e1e;
color: #c5c5c5;
padding: 15px;
border-radius: 5px;
font-family: "Courier New", Courier, monospace;
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
<h1>Git log</h1>
<div class="console">
{{ log_content }}
</div>
</body>
</html>

0 comments on commit bd62281

Please sign in to comment.