Commit 02be927b authored by Marcus Nordenberg's avatar Marcus Nordenberg Committed by Esteban Blanc

pkg: fix pwrrt package for debian x86_64

(cherry picked from commit 3c647fc3829441798185ec979420809cc6885f17)
parent 5a94f193
......@@ -43,10 +43,10 @@ fi
echo ""
echo ""
echo ""
echo "<b>Proview V${version:0:3}"
echo "<b>ProviewR V${version:0:3}"
echo "Version V$version"
echo ""
echo "Copyright 2005-${d:0:4} SSAB EMEA AB"
echo "Copyright 2005-${d:0:4} SSAB EMEA AB"
echo ""
echo "This program is free software; you can redistribute it and/or"
echo "modify it under the terms of the GNU General Public License as"
......@@ -104,6 +104,7 @@ echo "-- Create package tree"
mkdir -p $pkgroot/DEBIAN
mkdir -p $pkgroot/usr/share/doc/pwrrt
mkdir -p $pkgroot/etc/init.d
mkdir -p $pkgroot/etc/systemd/system
find $pkgroot -type d | xargs chmod 755
......@@ -111,8 +112,10 @@ find $pkgroot -type d | xargs chmod 755
cp $pkgsrc/control $pkgroot/DEBIAN
cp $pkgsrc/postinst $pkgroot/DEBIAN
cp $pkgsrc/prerm $pkgroot/DEBIAN
cp $pkgsrc/postrm $pkgroot/DEBIAN
chmod 755 $pkgroot/DEBIAN/postinst
chmod 755 $pkgroot/DEBIAN/prerm
chmod 755 $pkgroot/DEBIAN/postrm
chmod 644 $pkgroot/DEBIAN/control
# copyright
......@@ -128,11 +131,9 @@ gzip -fq --best $pkgroot/usr/share/doc/pwrrt/changelog.Debian
# Startup files
cp $pkgsrc/pwrp_profile $pkgroot/etc
chmod a+x $pkgroot/etc/pwrp_profile
cp $pkgsrc/pwr $pkgroot/etc/init.d
chmod a+x $pkgroot/etc/init.d/pwr
#cp $pkgsrc/gdhserver $pkgroot/etc/init.d
#chmod a+x $pkgroot/etc/init.d/gdhserver
cp $pkgsrc/pwr.service $pkgroot/etc/systemd/system/
# Man pages
mkdir -p $pkgroot/usr/share/man/man1
......@@ -147,39 +148,32 @@ gzip -fq --best $pkgroot/usr/share/man/man1/rt_rtt.1
# Copy proview
mkdir $pkgroot/usr/pwrrt
currentdir="`eval pwd`"
tarfile=$pwre_broot/$pwre_target/bld/pkg/pwrtmp.tar
cd $pwre_broot/$pwre_target/exp
#currentdir="`eval pwd`"
#tarfile=$pwre_broot/$pwre_target/bld/pkg/pwrtmp.tar
#cd $pwre_broot/$pwre_target/exp
echo "-- Copy release to package tree"
tar -cf $tarfile *
cd $pkgroot/usr/pwrrt
tar -xf $tarfile
rm $tarfile
cp -r $pwre_broot/$pwre_target/exp/* $pkgroot/usr/pwrrt/
##tar -cf $tarfile *
#cd $pkgroot/usr/pwrrt
#tar -xf $tarfile
#rm $tarfile
rm -r $pkgroot/usr/pwrrt/lib/*.a
rm -r $pkgroot/usr/pwrrt/exe/wb*
cp $pwr_eexe/wb_distr_keepboot.sh $pkgroot/usr/pwrrt/exe
cd $currentdir
#cd $currentdir
# Copy configuration files to cnf
cp $pkgsrc/proview.cnf $pkgroot/usr/pwrrt/cnf
# Copy op to cnf
mkdir $pkgroot/usr/pwrrt/cnf/op
cp $pwre_sroot/tools/pkg/$hw/op/.bashrc $pkgroot/usr/pwrrt/cnf/op
cp $pwre_sroot/tools/pkg/$hw/op/.bash_profile $pkgroot/usr/pwrrt/cnf/op
#cp $pwre_sroot/tools/pkg/$hw/op/.mwmrc $pkgroot/usr/pwrrt/cnf/op
cp $pwre_sroot/tools/pkg/$hw/op/.rtt_start $pkgroot/usr/pwrrt/cnf/op
cp $pwre_sroot/tools/pkg/$hw/op/.xtt_start $pkgroot/usr/pwrrt/cnf/op
#cp $pwre_sroot/tools/pkg/$hw/op/.xsession $pkgroot/usr/pwrrt/cnf/op
# Copy user to cnf
mkdir $pkgroot/usr/pwrrt/cnf/user
cp $pwre_sroot/tools/pkg/$hw/user/.bashrc $pkgroot/usr/pwrrt/cnf/user
cp $pwre_sroot/tools/pkg/$hw/user/.bash_profile $pkgroot/usr/pwrrt/cnf/user
#cp $pwre_sroot/tools/pkg/$hw/user/.mwmrc $pkgroot/usr/pwrrt/cnf/user
cp $pwre_sroot/tools/pkg/$hw/user/.rtt_start $pkgroot/usr/pwrrt/cnf/user
cp $pwre_sroot/tools/pkg/$hw/user/.xtt_start $pkgroot/usr/pwrrt/cnf/user
#cp $pwre_sroot/tools/pkg/$hw/user/.xsession $pkgroot/usr/pwrrt/cnf/user
# Create package
echo "-- Building package"
......
Package: pwrrt
Version: 5.7.2-1
Version: 5.7.0-3
Section: base
Priority: optional
Architecture: amd64
......@@ -17,6 +17,6 @@ Depends: libc6 (>= 2.28-10),
xterm,
xfonts-100dpi
Replaces: pwr34,pwr39,pwr40,pwr41,pwr42,pwr43,pwr44,pwr45,pwr46,pwr47,pwr48,pwr50,pwr51,pwr52,pwr53,pwr54,pwr55,pwr56
Maintainer: ProviewR <postmaster@proview.se>
Description: ProviewR runtime package
5.7.2-1 Base release
Maintainer: Proview <postmaster@proview.se>
Description:
5.7.0-3 Base release
This diff is collapsed.
#!/bin/sh
set -e
# Remove proview.cnf if we are purging
if [ "$1" = "purge" -a -e /etc/proview.cnf ]; then
rm /etc/proview.cnf
echo "-- Purged /etc/proview.cnf"
fi
......@@ -12,109 +12,34 @@ fi
# End automatically added section
proot="/pwrp"
aroot="/usr/pwrp/adm"
aroot="/usr/pwrp"
echo ""
echo -n "Do you wan't to remove project and users (y/n) [n] "
echo -n "Do you want to remove project and users (y/n) [n] "
read remove_all
if [ "$remove_all" = "y" ]; then
# Check that any user that is to be remoted isn't logged in
set +e
user_found=0
currentusers=`eval users`
userstr=""
checkuser=`eval echo $currentusers | grep "\bb55\b"`
if [ "$checkuser" != "" ]; then
user_found=1
userstr=$userstr" b55"
fi
checkuser=`eval echo $currentusers | grep "\bb66\b"`
if [ "$checkuser" != "" ]; then
user_found=1
userstr=$userstr" b66"
fi
checkuser=`eval echo $currentusers | grep "\bpwrp\b"`
if [ "$checkuser" != "" ]; then
user_found=1
userstr=$userstr" pwrp"
fi
checkuser=`eval echo $currentusers | grep "\bskiftel\b"`
if [ "$checkuser" != "" ]; then
user_found=1
userstr=$userstr" skiftel"
fi
if [ $user_found -eq 1 ]; then
echo "-- Current users: $currentusers"
echo "** Remove user will fail. Logout user $userstr first."
exit -1;
fi
set -e
echo "-- Remove user b55"
if grep -q "\bb55:" /etc/passwd; then
userdel b55
fi
if [ -e /home/b55 ]; then
rm -r /home/b55
fi
echo "-- Remove user b66"
if grep -q "\bb66:" /etc/passwd; then
userdel b66
fi
if [ -e /home/b66 ]; then
rm -r /home/b66
fi
echo "-- Remove user pwrp"
if grep -q "\bpwrp:" /etc/passwd; then
userdel pwrp
fi
if [ -e /home/pwrp ]; then
rm -r /home/pwrp
fi
echo "-- Remove user skiftel"
if grep -q "\bskiftel:" /etc/passwd; then
userdel skiftel
fi
if [ -e /home/skiftel ]; then
rm -r /home/skiftel
fi
if grep -q "\bb55:" /etc/group; then
groupdel b55
fi
if grep -q "\bb66:" /etc/group; then
groupdel b66
fi
if grep -q "\bpwrp:" /etc/group; then
groupdel pwrp
fi
if grep -q "\bskiftel:" /etc/group; then
groupdel skiftel
fi
echo "-- Remove project $proot"
for user in pwrp skiftel b55 b66; do
getent passwd ${user} >/dev/null 2>&1 && userdel -rf ${user} 2>/dev/null
echo "-- Removed user ${user}"
done
for grp in pwrp skiftel b55 b66; do
getent group ${grp} >/dev/null 2>&1 && groupdel ${grp}
echo "-- Removed group ${grp}"
done
echo "-- Removing projects..."
if [ -e $proot ]; then
rm -r $proot
rm -r $proot && echo "-- Removed project $proot"
fi
if [ -e $aroot ]; then
rm -r $aroot
rm -r $aroot && echo "-- Removed admin directory $proot"
fi
fi
# Remove startup
checklink=`eval ls /etc/rc2.d/S90pwr 2>/dev/null`
if [ "$checklink" != "" ]; then
rm /etc/rc2.d/S90pwr
systemctl disable pwr 2>/dev/null
if [ -e /etc/systemd/system/pwr.service ]; then
rm /etc/systemd/system/pwr.service
# Some symlinks are left in sysv after disabling pwr with systemd
update-rc.d pwr remove >/dev/null 2>&1
fi
# Remove jar-files on web directory
......
#!/bin/bash
#!/bin/sh
### BEGIN INIT INFO
# Provides: pwr
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Proview Runtime Environment.
# Description: Start Proview Runtime Environment.
# Provides: pwr
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Start ProviewR Runtime Environment
### END INIT INFO
#
# Start script for Proview runtime
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
wrapper="/tmp/rt_ini_wrapper"
killer="/tmp/pwr_killer"
. /etc/pwrp_profile
umask 002
create_wrapper()
{
if [ ! -e $wrapper ] ; then
echo "#!/bin/bash" > $wrapper
echo "source /etc/pwrp_profile" >> $wrapper
echo "umask 002" >> $wrapper
echo "\$pwr_exe/rt_ini \$* &" >> $wrapper
chmod a+rx $wrapper
if [ ! -e $wrapper ] ;then
echo "$wrapper not writable, check permissions"
exit
fi
fi
}
create_killer()
{
echo "#!/bin/bash" > $killer
echo "source /etc/pwrp_profile" >> $killer
echo "umask 002" >> $killer
echo "`ps ax | grep "rt_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "rs_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "ra_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "sev_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "opc_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "plc_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "jpwr.rt" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "eval `ipcs -s|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm sem %s;", $2}'`" >> $killer
echo "eval `ipcs -q|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm msg %s;", $2}'`" >> $killer
echo "eval `ipcs -m|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm shm %s;", $2}'`" >> $killer
node=`eval uname -n`
applfile=$pwrp_load"/ld_appl_"$node"_"$PWR_BUS_ID".txt"
if [ -e $applfile ]; then
stored_ifs=$IFS
IFS=' ,'
while read appid appname appload apprun appfile appprio appdebug apparg; do
if [ -n "$appid" ] && [ "${appid:0:1}" != "#" ]; then
if [ $appid != "pwr_neth" ] &&
[ $appid != "pwr_qmon" ] &&
[ $appid != "pwr_nacp" ] &&
[ $appid != "pwr_io" ] &&
[ $appid != "pwr_tmon" ] &&
[ $appid != "pwr_emon" ] &&
[ $appid != "pwr_alim" ] &&
[ $appid != "pwr_bck" ] &&
[ $appid != "pwr_linksup" ] &&
[ $appid != "pwr_trend" ] &&
[ $appid != "pwr_fast" ] &&
[ $appid != "pwr_remh" ] &&
[ $appid != "pwr_remlog" ] &&
[ $appid != "pwr_webmon" ] &&
[ $appid != "pwr_webmonmh" ] &&
[ $appid != "pwr_webmonelog" ] &&
[ $appid != "pwr_opc_server" ] &&
[ $appid != "pwr_post" ] &&
[ $appid != "pwr_report" ] &&
[ $appid != "pwr_sevhistmon" ] &&
[ $appid != "pwr_sev_server" ] &&
[ $appid != "pwr_powerlink" ] &&
[ $appid != "pwr_sim" ] &&
[ $appid != "pwr_plc" ] &&
[ "$appfile" != "rt_io_comm" ] &&
[ ${appid:0:8} != "pwr_plc_" ]; then
echo "killall $appname" >> $killer
fi
fi
done < $applfile
IFS=$stored_ifs
fi
echo "if [ -e $pwrp_exe/pwrp_stop.sh ]; then" >> $killer
echo " source $pwrp_exe/pwrp_stop.sh" >> $killer
echo "fi" >> $killer
echo "rm /tmp/pwr*\$PWR_BUS_ID" >> $killer
chmod a+rx $killer
if [ ! -e $killer ] ;then
echo "$killer not writable, check permissions"
exit
fi
}
pwr_start()
{
create_wrapper
if [ `whoami` == "pwrp" ];then
$wrapper
else
sudo -u pwrp $wrapper
fi
}
pwr_stop()
{
create_wrapper
if [ `whoami` == "pwrp" ];then
$wrapper -s
if [ -e $pwrp_exe/pwrp_stop.sh ]; then
source $pwrp_exe/pwrp_stop.sh
fi
else
sudo -u pwrp $wrapper -s
if [ -e $pwrp_exe/pwrp_stop.sh ]; then
sudo -u pwrp source $pwrp_exe/pwrp_stop.sh
fi
fi
while [ "`ps aux | grep -v grep | grep rt_`" != "" ] ; do sleep 1; done
}
pwr_reload()
{
if [ `whoami` == "pwrp" ];then
$pwr_exe/rt_ini_wrapper -r
else
sudo -u pwrp $pwr_exe/rt_ini_wrapper -r
fi
}
pwr_kill()
{
create_killer
if [ `whoami` == "pwrp" ];then
$killer
else
sudo -u pwrp $killer
fi
}
case "$1"
in
start)
echo "Start Proview Runtime Environment."
pwr_start
echo "Done."
;;
stop)
echo "Stop Proveiw Runtime Environment."
pwr_stop
echo "Done."
;;
restart)
echo "Restart Proview Runtime Environment."
echo "Closing down..."
pwr_stop
sleep 1
echo "Starting..."
pwr_start
echo "Done."
;;
reload)
echo "Reload Proview Runtime Environment"
pwr_reload
echo "Done."
;;
kill)
echo "Remove all processes and resources for Proview Runtime Environment"
pwr_kill
echo "Done."
;;
reset)
echo "Remove all processes and resources for Proview Runtime Environment"
pwr_kill
echo "Done."
;;
*)
echo " pwr Start and stop Proview Runtime Environment" >&2
echo "" >&2
echo " Usage:" >&2
echo " pwr start|stop|restart|reload|reset" >&2
echo "" >&2
echo " start Start Runtime environment" >&2
echo " stop Stop Runtime environment" >&2
echo " restart First stop and then start Runtime environment" >&2
echo " reload Soft restart of Runtime environment" >&2
echo " reset Remove all processes and resources" >&2
echo "" >&2
exit 1
;;
esac
exit 0
. /lib/lsb/init-functions
DAEMON=$pwr_exe/rt_ini
PIDFILE=/run/pwr/pwr.pid
test -x $DAEMON || exit 5
LOCKFILE=/run/lock/pwrdate
RUNASUSER=pwrp
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
case $1 in
start)
echo ""
log_daemon_msg "Starting ProviewR Runtime" "rt_ini"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi
(
flock -w 180 10
start-stop-daemon --start --oknodo --pidfile $PIDFILE --startas $DAEMON -- -D
sleep 5
) 10>$LOCKFILE
log_end_msg $?
;;
stop)
echo ""
log_daemon_msg "Stopping ProviewR Runtime" "rt_ini"
# Store PID of rt_ini before sending SIGTERM
PID=0
if [ -e $PIDFILE ]; then
read PID < $PIDFILE
else
echo ""
log_daemon_msg "No pidfile present. Did you start ProviewR as a system service?" "rt_ini"
fi
rt_ini -s &>/dev/null
# Sleep until process is gone
while kill -0 $PID &>/dev/null; do
sleep 1
done
# Did we manage to bring everything down correct? Check to see if there are IPCs still left for the process
if [ ! -z $PID ]; then
ipcs -p | grep $PID &>/dev/null
if [ $? -eq 0 ]; then
echo ""
log_daemon_msg "IPC objects still present (abnormal termination of ProviewR?) running kill script" "rt_ini"
. $pwr_exe/pwr_stop.sh &>/dev/null
fi
fi
# Check for the presence of pwr_* tmp files. If there are any something must have gone wrong in the closing of rt_ini
ls -1 /tmp/pwr_*_$PWR_BUS_ID &>/dev/null
if [ $? -eq 0 ]; then
echo "\n"
log_daemon_msg "Temporary files still present (abnormal termination of ProviewR?) running kill script" "rt_ini"
. $pwr_exe/pwr_stop.sh &>/dev/null
fi
log_end_msg $?
rm -f $LOCKFILE
;;
restart)
$0 stop && sleep 2 && $0 start
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
PID=0
if [ -e $PIDFILE ]; then
read PID < $PIDFILE
else
echo ""
log_daemon_msg "No pidfile present, ProviewR doesn't seem to be running or you are running ProviewR as a standard user with -P" "rt_ini"
exit 1
fi
rt_ini -r &>/dev/null
;;
status)
status_of_proc $DAEMON "ProviewR Runtime"
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
exit 2
;;
esac
[Unit]
Documentation=man:pwr(1)
Description=ProviewR Runtime Environment
After=network-online.target
Wants=network-online.target
[Service]
EnvironmentFile=-/pwrp/common/load/pwr_environment
Type=forking
Restart=no
TimeoutSec=15
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BROADCAST
# TODO Share private tmp with rt_xtt
PrivateTmp=no
KillMode=control-group
GuessMainPID=no
PIDFile=/run/pwr/pwr.pid
RemainAfterExit=no
RuntimeDirectory=pwr
RemoveIPC=yes
ExecStart=/etc/init.d/pwr start
ExecStop=/etc/init.d/pwr stop
# The reload function is not to be trusted, if for instance, you're running profibus/profinet.
# There are probably more cases in which this is cheesy...
ExecReload=/etc/init.d/pwr reload
User=pwrp
Group=pwrp
StandardOutput=journal
StandardError=inherit
SyslogIdentifier=ProviewR
LimitCORE=infinity
LimitRTPRIO=infinity
IOSchedulingClass=best-effort
IOSchedulingPriority=3
[Install]
WantedBy=multi-user.target
bus_id=""
if [ -e /etc/proview.cnf ]; then
bus_id=`eval cat /etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'`
......@@ -20,10 +19,20 @@ export pwr_load=$pwrb_root/load
export pwr_lis=$pwrb_root/lis
export pwr_doc=$pwrb_root/doc
export pwrp_exe=$pwrp_root/x86_64_linux/exe
export pwrp_lib=$pwrp_root/x86_64_linux/lib
export pwrp_obj=$pwrp_root/x86_64_linux/obj
export pwrp_lis=$pwrp_root/x86_64_linux/lis
# Fetch arch
if [ -e /pwrp ]; then
for dir in `ls -1 /pwrp`; do
[[ "${dir}" == "common" ]] && continue
arch=${dir}
break
done
# Set arch specific env variables
for env in exe obj lis lib; do
export pwrp_${env}=${pwrp_root}/${arch}/${env}
done
fi
export pwrp_inc=$pwrp_root/common/inc
export pwrp_load=$pwrp_root/common/load
export pwrp_log=$pwrp_root/common/log
......@@ -32,19 +41,19 @@ export pwrp_web=$web_dir
export pwra_db=/usr/pwrp/adm/db
# Check /usr/local first since it ought to have priority
# Check /usr/local first since it ought to have priority
jdk=`eval ls -1 /usr/local | sort -r | grep ^jdk | head -1`
# Check if any JRE is present in /usr/local
if [ -z "$jdk" ]; then
jdk=`eval ls -1 /usr/local | sort -r | grep ^jre | head -1`
fi
# If no local jdk/jres were found check for openjdk. Debian can have a default-java
# If no local jdk/jres were found check for openjdk. Debian should have a default-java
# symlink in /usr/lib/jvm which can be changed with update-java-alternatives if openjdk
# is in use. If no default-java excists try to use the one with the highest version
# is in use. If no default-java excists use the one with the highest version
if [ -z "$jdk" ]; then
if [ -e /usr/lib/jvm/default-java ]; then
jdk=`eval realpath -qe /usr/lib/jvm/default-java`
else
elif [ -e /usr/lib/jvm ]; then
jdk_name=`eval ls -1 /usr/lib/jvm | sort -r | grep ^java | head -1`
jdk=`eval realpath -qe /usr/lib/jvm/$jdk_name`
unset jdk_name
......@@ -64,11 +73,12 @@ fi
PATH=$PATH:$pwr_exe:$pwrp_exe:$jdk_home
#symbols to define start/stop commands for PWR
alias pwr_stop='/etc/init.d/pwr stop'
alias pwr_stop.sh="/etc/init.d/pwr stop"
alias pwr_start="/etc/init.d/pwr start"
alias pwr="/etc/init.d/pwr"
alias boot="/usr/bin/sudo /sbin/reboot"
alias pwr_stop='pwr stop'
alias pwr_start="pwr start"
pwr() {
systemctl "$1" pwr.service
}
if [ -e $pwrp_exe/profile ]; then
source $pwrp_exe/profile
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment