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 ...@@ -43,10 +43,10 @@ fi
echo "" echo ""
echo "" echo ""
echo "" echo ""
echo "<b>Proview V${version:0:3}" echo "<b>ProviewR V${version:0:3}"
echo "Version V$version" echo "Version V$version"
echo "" echo ""
echo "Copyright 2005-${d:0:4} SSAB EMEA AB" echo "Copyright 2005-${d:0:4} SSAB EMEA AB"
echo "" echo ""
echo "This program is free software; you can redistribute it and/or" 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" echo "modify it under the terms of the GNU General Public License as"
...@@ -104,6 +104,7 @@ echo "-- Create package tree" ...@@ -104,6 +104,7 @@ echo "-- Create package tree"
mkdir -p $pkgroot/DEBIAN mkdir -p $pkgroot/DEBIAN
mkdir -p $pkgroot/usr/share/doc/pwrrt mkdir -p $pkgroot/usr/share/doc/pwrrt
mkdir -p $pkgroot/etc/init.d mkdir -p $pkgroot/etc/init.d
mkdir -p $pkgroot/etc/systemd/system
find $pkgroot -type d | xargs chmod 755 find $pkgroot -type d | xargs chmod 755
...@@ -111,8 +112,10 @@ 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/control $pkgroot/DEBIAN
cp $pkgsrc/postinst $pkgroot/DEBIAN cp $pkgsrc/postinst $pkgroot/DEBIAN
cp $pkgsrc/prerm $pkgroot/DEBIAN cp $pkgsrc/prerm $pkgroot/DEBIAN
cp $pkgsrc/postrm $pkgroot/DEBIAN
chmod 755 $pkgroot/DEBIAN/postinst chmod 755 $pkgroot/DEBIAN/postinst
chmod 755 $pkgroot/DEBIAN/prerm chmod 755 $pkgroot/DEBIAN/prerm
chmod 755 $pkgroot/DEBIAN/postrm
chmod 644 $pkgroot/DEBIAN/control chmod 644 $pkgroot/DEBIAN/control
# copyright # copyright
...@@ -128,11 +131,9 @@ gzip -fq --best $pkgroot/usr/share/doc/pwrrt/changelog.Debian ...@@ -128,11 +131,9 @@ gzip -fq --best $pkgroot/usr/share/doc/pwrrt/changelog.Debian
# Startup files # Startup files
cp $pkgsrc/pwrp_profile $pkgroot/etc cp $pkgsrc/pwrp_profile $pkgroot/etc
chmod a+x $pkgroot/etc/pwrp_profile
cp $pkgsrc/pwr $pkgroot/etc/init.d cp $pkgsrc/pwr $pkgroot/etc/init.d
chmod a+x $pkgroot/etc/init.d/pwr chmod a+x $pkgroot/etc/init.d/pwr
#cp $pkgsrc/gdhserver $pkgroot/etc/init.d cp $pkgsrc/pwr.service $pkgroot/etc/systemd/system/
#chmod a+x $pkgroot/etc/init.d/gdhserver
# Man pages # Man pages
mkdir -p $pkgroot/usr/share/man/man1 mkdir -p $pkgroot/usr/share/man/man1
...@@ -147,39 +148,32 @@ gzip -fq --best $pkgroot/usr/share/man/man1/rt_rtt.1 ...@@ -147,39 +148,32 @@ gzip -fq --best $pkgroot/usr/share/man/man1/rt_rtt.1
# Copy proview # Copy proview
mkdir $pkgroot/usr/pwrrt mkdir $pkgroot/usr/pwrrt
currentdir="`eval pwd`" #currentdir="`eval pwd`"
tarfile=$pwre_broot/$pwre_target/bld/pkg/pwrtmp.tar #tarfile=$pwre_broot/$pwre_target/bld/pkg/pwrtmp.tar
cd $pwre_broot/$pwre_target/exp #cd $pwre_broot/$pwre_target/exp
echo "-- Copy release to package tree" echo "-- Copy release to package tree"
tar -cf $tarfile * cp -r $pwre_broot/$pwre_target/exp/* $pkgroot/usr/pwrrt/
cd $pkgroot/usr/pwrrt ##tar -cf $tarfile *
tar -xf $tarfile #cd $pkgroot/usr/pwrrt
rm $tarfile #tar -xf $tarfile
#rm $tarfile
rm -r $pkgroot/usr/pwrrt/lib/*.a rm -r $pkgroot/usr/pwrrt/lib/*.a
rm -r $pkgroot/usr/pwrrt/exe/wb* rm -r $pkgroot/usr/pwrrt/exe/wb*
cp $pwr_eexe/wb_distr_keepboot.sh $pkgroot/usr/pwrrt/exe cp $pwr_eexe/wb_distr_keepboot.sh $pkgroot/usr/pwrrt/exe
cd $currentdir #cd $currentdir
# Copy configuration files to cnf # Copy configuration files to cnf
cp $pkgsrc/proview.cnf $pkgroot/usr/pwrrt/cnf cp $pkgsrc/proview.cnf $pkgroot/usr/pwrrt/cnf
# Copy op to cnf # Copy op to cnf
mkdir $pkgroot/usr/pwrrt/cnf/op 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/.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/.xtt_start $pkgroot/usr/pwrrt/cnf/op
#cp $pwre_sroot/tools/pkg/$hw/op/.xsession $pkgroot/usr/pwrrt/cnf/op
# Copy user to cnf # Copy user to cnf
mkdir $pkgroot/usr/pwrrt/cnf/user 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/.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/.xtt_start $pkgroot/usr/pwrrt/cnf/user
#cp $pwre_sroot/tools/pkg/$hw/user/.xsession $pkgroot/usr/pwrrt/cnf/user
# Create package # Create package
echo "-- Building package" echo "-- Building package"
......
Package: pwrrt Package: pwrrt
Version: 5.7.2-1 Version: 5.7.0-3
Section: base Section: base
Priority: optional Priority: optional
Architecture: amd64 Architecture: amd64
...@@ -17,6 +17,6 @@ Depends: libc6 (>= 2.28-10), ...@@ -17,6 +17,6 @@ Depends: libc6 (>= 2.28-10),
xterm, xterm,
xfonts-100dpi xfonts-100dpi
Replaces: pwr34,pwr39,pwr40,pwr41,pwr42,pwr43,pwr44,pwr45,pwr46,pwr47,pwr48,pwr50,pwr51,pwr52,pwr53,pwr54,pwr55,pwr56 Replaces: pwr34,pwr39,pwr40,pwr41,pwr42,pwr43,pwr44,pwr45,pwr46,pwr47,pwr48,pwr50,pwr51,pwr52,pwr53,pwr54,pwr55,pwr56
Maintainer: ProviewR <postmaster@proview.se> Maintainer: Proview <postmaster@proview.se>
Description: ProviewR runtime package Description:
5.7.2-1 Base release 5.7.0-3 Base release
...@@ -16,176 +16,125 @@ proot="/pwrp" ...@@ -16,176 +16,125 @@ proot="/pwrp"
aroot="/usr/pwrp/adm" aroot="/usr/pwrp/adm"
# Create users... # Create users...
new_user=0 echo "-- Creating users/groups..."
for grp in pwrp b55 b66 skiftel; do
if getent group pwrp > /dev/null; then if getent group ${grp} >/dev/null; then
echo "-- group pwrp already exist" echo "-- Group ${grp} already exist. OK!"
else else
if groupadd pwrp; then if groupadd ${grp}; then
echo "-- group pwrp added" echo "-- Group ${grp} added..."
fi fi
fi
if getent group b55 > /dev/null; then
echo "-- group b55 already exist"
else
if groupadd b55; then
echo "-- group b55 added"
fi fi
fi done
if getent group b66 > /dev/null; then # Do we have a pwrp user already?
echo "-- group b66 already exist" if getent passwd pwrp >/dev/null; then
echo "-- User pwrp already exist. OK!"
else else
if groupadd b66; then if useradd --create-home --shell /bin/bash --password aaupl/kQs1p3U --gid pwrp --groups b55,b66,skiftel --home-dir /home/pwrp pwrp; then
echo "-- group b66 added" echo "-- User pwrp added..."
fi fi
fi
if getent group skiftel > /dev/null; then
echo "-- group skiftel already exist"
else
if groupadd skiftel; then
echo "-- group skiftel added"
fi
fi
if getent passwd pwrp > /dev/null; then # If all went well we copy proview specific startup scripts to the home folder
echo "-- user pwrp already exist" if [ -e /home/pwrp ]; then
else
new_user=1
if useradd -s /bin/bash -p aaupl/kQs1p3U -g pwrp -G b55,b66,skiftel -d /home/pwrp pwrp; then
echo "-- user pwrp added"
fi
if [ ! -e /home/pwrp ]; then
mkdir /home/pwrp
cp /usr/pwrrt/cnf/user/.bashrc /home/pwrp
cp /usr/pwrrt/cnf/user/.bash_profile /home/pwrp
# cp /usr/pwrrt/cnf/user/.mwmrc /home/pwrp
cp /usr/pwrrt/cnf/user/.rtt_start /home/pwrp cp /usr/pwrrt/cnf/user/.rtt_start /home/pwrp
chmod a+x /home/pwrp/.rtt_start chmod a+x /home/pwrp/.rtt_start
cp /usr/pwrrt/cnf/user/.xtt_start /home/pwrp cp /usr/pwrrt/cnf/user/.xtt_start /home/pwrp
chmod a+x /home/pwrp/.xtt_start chmod a+x /home/pwrp/.xtt_start
# cp /usr/pwrrt/cnf/user/.xsession /home/pwrp
chown -R pwrp /home/pwrp
chgrp -R pwrp /home/pwrp
fi fi
# Add to group dialout # Add pwrp to group dialout
if getent group dialout > /dev/null; then if getent group dialout >/dev/null; then
usermod -a -G dialout pwrp usermod -a -G dialout pwrp && echo "-- User 'pwrp' added to group 'dialout'..." || echo "-- Unable to add user 'pwrp' to group 'dialout'!"
fi fi
fi fi
if getent passwd skiftel > /dev/null; then if getent passwd skiftel >/dev/null; then
echo "-- user skiftel already exist" echo "-- User skiftel already exist. OK!"
else else
new_user=1 if useradd --create-home --shell /bin/bash --password aa6NzxS/aBgP6 --gid skiftel --groups pwrp --home-dir /home/skiftel skiftel; then
echo "-- User skiftel added..."
if useradd -s /bin/bash -p aa6NzxS/aBgP6 -g skiftel -G pwrp -d /home/skiftel skiftel; then
echo "-- user skiftel added"
fi fi
if [ ! -e /home/skiftel ]; then # If all went well we copy proview specific startup scripts to the home folder
mkdir /home/skiftel if [ -e /home/skiftel ]; then
cp /usr/pwrrt/cnf/user/.bashrc /home/skiftel
cp /usr/pwrrt/cnf/user/.bash_profile /home/skiftel
# cp /usr/pwrrt/cnf/user/.mwmrc /home/skiftel
cp /usr/pwrrt/cnf/user/.rtt_start /home/skiftel cp /usr/pwrrt/cnf/user/.rtt_start /home/skiftel
chmod a+x /home/skiftel/.rtt_start chmod a+x /home/skiftel/.rtt_start
cp /usr/pwrrt/cnf/user/.xtt_start /home/skiftel cp /usr/pwrrt/cnf/user/.xtt_start /home/skiftel
chmod a+x /home/skiftel/.xtt_start chmod a+x /home/skiftel/.xtt_start
# cp /usr/pwrrt/cnf/user/.xsession /home/skiftel
chown -R pwrp /home/skiftel # And change group ownership of skiftel's home folder to pwrp
chgrp -R pwrp /home/skiftel chgrp -R pwrp /home/skiftel
fi fi
fi fi
if getent passwd b55 > /dev/null; then # Setup the operator group memberships
new_user=1 groups="pwrp"
getent group audio >/dev/null && groups+=",audio"
# Check if group audio exist # Add the user b55
if getent group audio > /dev/null; then if getent passwd b55 >/dev/null; then
groups="pwrp,audio" echo "-- User b55 already exist. OK!"
else else
groups="pwrp" if useradd --create-home --shell /bin/bash --password aaQPClsglxJP6 --gid b55 --groups $groups --home-dir /home/b55 b55; then
echo "-- User b55 added..."
fi fi
if useradd -s /bin/bash -p aaQPClsglxJP6 -g b55 -G $groups -d /home/b55 b55; then if [ -e /home/b55 ]; then
echo "-- user b55 added"
fi
if [ ! -e /home/b55 ]; then
mkdir /home/b55
cp /usr/pwrrt/cnf/op/.bashrc /home/b55
cp /usr/pwrrt/cnf/op/.bash_profile /home/b55
# cp /usr/pwrrt/cnf/op/.mwmrc /home/b55
cp /usr/pwrrt/cnf/op/.rtt_start /home/b55 cp /usr/pwrrt/cnf/op/.rtt_start /home/b55
chmod a+x /home/b55/.rtt_start chmod a+x /home/b55/.rtt_start
cp /usr/pwrrt/cnf/op/.xtt_start /home/b55 cp /usr/pwrrt/cnf/op/.xtt_start /home/b55
chmod a+x /home/b55/.xtt_start chmod a+x /home/b55/.xtt_start
# cp /usr/pwrrt/cnf/op/.xsession /home/b55
chown -R b55 /home/b55 chown -R b55 /home/b55
chgrp -R pwrp /home/b55 chgrp -R pwrp /home/b55
chmod g+rwx /home/b55 chmod g+rws /home/b55
fi fi
fi fi
if getent passwd b66 > /dev/null; then if getent passwd b66 >/dev/null; then
new_user=1 echo "-- User b66 already exist. OK!"
else
# Check if group audio exist if useradd --create-home --shell /bin/bash --password 1P4JdWA5HqSMQ --gid b66 --groups $groups --home-dir /home/b66 b66; then
if getent group audio > /dev/null; then echo "-- User b66 added..."
groups="pwrp,audio"
else
groups="pwrp"
fi fi
if useradd -s /bin/bash -p aae.nHgHbfUpw -g b66 -G $groups -d /home/b66 b66; then if [ -e /home/b66 ]; then
echo "-- user b66 added"
fi
if [ ! -e /home/b66 ]; then
mkdir /home/b66
cp /usr/pwrrt/cnf/op/.bashrc /home/b66
cp /usr/pwrrt/cnf/op/.bash_profile /home/b66
# cp /usr/pwrrt/cnf/op/.mwmrc /home/b66
cp /usr/pwrrt/cnf/op/.rtt_start /home/b66 cp /usr/pwrrt/cnf/op/.rtt_start /home/b66
chmod a+x /home/b66/.rtt_start chmod a+x /home/b55/.rtt_start
cp /usr/pwrrt/cnf/op/.xtt_start /home/b66 cp /usr/pwrrt/cnf/op/.xtt_start /home/b66
chmod a+x /home/b66/.xtt_start chmod a+x /home/b55/.xtt_start
# cp /usr/pwrrt/cnf/op/.xsession /home/b66
chown -R b66 /home/b66 chown -R b66 /home/b66
chgrp -R pwrp /home/b66 chgrp -R pwrp /home/b66
chmod g+rwx /home/b66 chmod g+rws /home/b66
fi fi
fi fi
chown -R pwrp /usr/pwrrt chown -R pwrp /usr/pwrrt
chgrp -R pwrp /usr/pwrrt chgrp -R pwrp /usr/pwrrt
chmod u+s /usr/pwrrt/exe/rt_ini setcap cap_net_admin,cap_net_raw,cap_net_broadcast+eip /usr/pwrrt/exe/rt_ini
chmod u+s /usr/pwrrt/exe/rt_rtt
#chmod u+s /usr/pwrrt/exe/rt_ini
#chmod u+s /usr/pwrrt/exe/rt_rtt
#chmod u+s /usr/pwrrt/exe/rt_xtt #chmod u+s /usr/pwrrt/exe/rt_xtt
chmod u+s /usr/pwrrt/exe/rt_bck #chmod u+s /usr/pwrrt/exe/rt_bck
chmod u+s /usr/pwrrt/exe/rt_gdhget #chmod u+s /usr/pwrrt/exe/rt_gdhget
chown root /usr/pwrrt/exe/rs_remote_alcm #chown root /usr/pwrrt/exe/rs_remote_alcm
chmod u+s /usr/pwrrt/exe/rs_remote_alcm #chmod u+s /usr/pwrrt/exe/rs_remote_alcm
if getent group dialout > /dev/null; then #if getent group dialout > /dev/null; then
chgrp dialout /usr/pwrrt/exe/rs_remote_serial # chgrp dialout /usr/pwrrt/exe/rs_remote_serial
chmod ug+s /usr/pwrrt/exe/rs_remote_serial # chmod ug+s /usr/pwrrt/exe/rs_remote_serial
chgrp dialout /usr/pwrrt/exe/rs_remote_3964r #chgrp dialout /usr/pwrrt/exe/rs_remote_3964r
chmod ug+s /usr/pwrrt/exe/rs_remote_3964r #chmod ug+s /usr/pwrrt/exe/rs_remote_3964r
fi #fi
if [ -e /usr/pwrrt/exe/rt_powerlink ]; then #if [ -e /usr/pwrrt/exe/rt_powerlink ]; then
chown root /usr/pwrrt/exe/rt_powerlink #chown root /usr/pwrrt/exe/rt_powerlink
chmod u+s /usr/pwrrt/exe/rt_powerlink #chmod u+s /usr/pwrrt/exe/rt_powerlink
fi #fi
chown root /usr/pwrrt/exe/rt_mozilla #chown root /usr/pwrrt/exe/rt_mozilla
chmod u+s /usr/pwrrt/exe/rt_mozilla #chmod u+s /usr/pwrrt/exe/rt_mozilla
# Copy configuration files # Copy configuration files
new_cnf=0 new_cnf=0
...@@ -194,30 +143,30 @@ if [ ! -e /etc/proview.cnf ]; then ...@@ -194,30 +143,30 @@ if [ ! -e /etc/proview.cnf ]; then
new_cnf=1 new_cnf=1
fi fi
# Add pwrp_profile to profile # Source pwrp_profile from both profile and bash.bashrc
if ! grep -q "/etc/pwrp_profile\b" /etc/profile; then for cnf_file in /etc/profile /etc/bash.bashrc; do
cat >> /etc/profile <<-EOF if ! grep -q "/etc/pwrp_profile\b" ${cnf_file}; then
if [ -e /etc/pwrp_profile ]; then cat >> ${cnf_file} <<-EOF
source /etc/pwrp_profile [[ -e /etc/pwrp_profile ]] && . /etc/pwrp_profile
EOF
fi fi
EOF done
fi
# Create startup link # Create startup link
set +e # set +e
checklink=`eval ls /etc/rc2.d/S90pwr 2>/dev/null` # checklink=`eval ls /etc/rc2.d/S90pwr 2>/dev/null`
set -e # set -e
if [ "$checklink" != "" ]; then # if [ "$checklink" != "" ]; then
rm /etc/rc2.d/S90pwr # rm /etc/rc2.d/S90pwr
fi # fi
ln -s /etc/init.d/pwr /etc/rc2.d/S90pwr # ln -s /etc/init.d/pwr /etc/rc2.d/S90pwr
set +e # set +e
checklink=`eval ls /etc/rc2.d/S91gdhserver 2>/dev/null` # checklink=`eval ls /etc/rc2.d/S91gdhserver 2>/dev/null`
set -e # set -e
if [ "$checklink" != "" ]; then # if [ "$checklink" != "" ]; then
rm /etc/rc2.d/S91gdhserver # rm /etc/rc2.d/S91gdhserver
fi # fi
# Obsolete # Obsolete
#ln -s /etc/init.d/gdhserver /etc/rc2.d/S91gdhserver #ln -s /etc/init.d/gdhserver /etc/rc2.d/S91gdhserver
...@@ -324,8 +273,8 @@ EOF ...@@ -324,8 +273,8 @@ EOF
fi fi
# Add directories to nginx # Add directories to nginx
if [ -e /etc/nginx/sites-enabled/default ]; then if [ -e /etc/nginx/sites-available/default ]; then
if ! egrep -q "location /pwrp_web/" /etc/nginx/sites-enabled/default; then if ! egrep -q "location /pwrp_web/" /etc/nginx/sites-available/default; then
awk ' awk '
BEGIN { BEGIN {
inserver = 0; inserver = 0;
...@@ -365,57 +314,36 @@ BEGIN { ...@@ -365,57 +314,36 @@ BEGIN {
} }
else else
printf( "%s\n", $0); printf( "%s\n", $0);
}' /etc/nginx/sites-enabled/default > /etc/nginx/sites-enabled/default.new }' /etc/nginx/sites-available/default > /etc/nginx/sites-available/default.new
mv /etc/nginx/sites-enabled/default.new /etc/nginx/sites-enabled/default cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old
mv /etc/nginx/sites-available/default.new /etc/nginx/sites-available/default
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
fi fi
fi fi
#
# Set owner on preinstalled I/O systems
#
if [ -e /lib/udev/devices/qbus ]; then
chown pwrp:pwrp /lib/udev/devices/qbus
fi
if [ -e /lib/udev/devices/pbus1 ]; then
chown pwrp:pwrp /lib/udev/devices/pbus1
fi
if [ -e /lib/udev/devices/pbus2 ]; then
chown pwrp:pwrp /lib/udev/devices/pbus2
fi
changes=0 changes=0
if [ $new_user -eq 1 ]; then if [ $new_cnf -eq 1 ]; then
changes=1
elif [ $new_cnf -eq 1 ]; then
changes=1 changes=1
elif [ $new_project -eq 1 ]; then elif [ $new_project -eq 1 ]; then
changes=1 changes=1
fi fi
if [ $changes -ne 0 ]; then echo ""
echo "" echo "***********************************************************"
echo "" echo " Don't forget to do this :"
echo "***********************************************************" echo ""
echo " Don't forget to do this :"
echo ""
fi
if [ $new_cnf -eq 1 ]; then if [ $new_cnf -eq 1 ]; then
echo "-- Enter QcomBusId in /etc/proview.cnf" echo "-- Enter QcomBusId in /etc/proview.cnf"
fi fi
#if [ $new_user -eq 1 ]; then
# echo "-- Enter OpPlace object as argument to rt_xtt in /home/b55/.xtt_start"
#fi
if [ $new_project -eq 1 ]; then if [ $new_project -eq 1 ]; then
nodename=`eval uname -n` nodename=`eval uname -n`
echo "-- Distribute project to $nodename" echo "-- Distribute project to $nodename"
fi fi
if [ $changes -ne 0 ]; then echo "-- Once you have a project setup, enable the pwr service with:"
echo "" echo " # systemctl enable pwr"
echo "***********************************************************" echo "***********************************************************"
echo "" echo ""
fi
#!/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 ...@@ -12,109 +12,34 @@ fi
# End automatically added section # End automatically added section
proot="/pwrp" proot="/pwrp"
aroot="/usr/pwrp/adm" aroot="/usr/pwrp"
echo "" 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 read remove_all
if [ "$remove_all" = "y" ]; then if [ "$remove_all" = "y" ]; then
for user in pwrp skiftel b55 b66; do
# Check that any user that is to be remoted isn't logged in getent passwd ${user} >/dev/null 2>&1 && userdel -rf ${user} 2>/dev/null
set +e echo "-- Removed user ${user}"
user_found=0 done
currentusers=`eval users` for grp in pwrp skiftel b55 b66; do
userstr="" getent group ${grp} >/dev/null 2>&1 && groupdel ${grp}
checkuser=`eval echo $currentusers | grep "\bb55\b"` echo "-- Removed group ${grp}"
if [ "$checkuser" != "" ]; then done
user_found=1 echo "-- Removing projects..."
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"
if [ -e $proot ]; then if [ -e $proot ]; then
rm -r $proot rm -r $proot && echo "-- Removed project $proot"
fi fi
if [ -e $aroot ]; then if [ -e $aroot ]; then
rm -r $aroot rm -r $aroot && echo "-- Removed admin directory $proot"
fi fi
fi fi
# Remove startup systemctl disable pwr 2>/dev/null
checklink=`eval ls /etc/rc2.d/S90pwr 2>/dev/null` if [ -e /etc/systemd/system/pwr.service ]; then
if [ "$checklink" != "" ]; then rm /etc/systemd/system/pwr.service
rm /etc/rc2.d/S90pwr # Some symlinks are left in sysv after disabling pwr with systemd
update-rc.d pwr remove >/dev/null 2>&1
fi fi
# Remove jar-files on web directory # Remove jar-files on web directory
......
#!/bin/bash #!/bin/sh
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: pwr # Provides: pwr
# Required-Start: networking # Required-Start: $network $syslog
# Required-Stop: networking # Required-Stop: $network $syslog
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop:
# Short-Description: Start Proview Runtime Environment. # Short-Description: Start ProviewR Runtime Environment
# Description: Start Proview Runtime Environment.
### END INIT INFO ### 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 . /etc/pwrp_profile
umask 002 . /lib/lsb/init-functions
create_wrapper() DAEMON=$pwr_exe/rt_ini
{ PIDFILE=/run/pwr/pwr.pid
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() test -x $DAEMON || exit 5
{
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 LOCKFILE=/run/lock/pwrdate
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 RUNASUSER=pwrp
echo "eval `ipcs -q|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm msg %s;", $2}'`" >> $killer UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
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 case $1 in
if [ ! -e $killer ] ;then start)
echo "$killer not writable, check permissions" echo ""
exit log_daemon_msg "Starting ProviewR Runtime" "rt_ini"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi 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"
pwr_start() # Store PID of rt_ini before sending SIGTERM
{ PID=0
create_wrapper if [ -e $PIDFILE ]; then
if [ `whoami` == "pwrp" ];then read PID < $PIDFILE
$wrapper
else else
sudo -u pwrp $wrapper echo ""
log_daemon_msg "No pidfile present. Did you start ProviewR as a system service?" "rt_ini"
fi fi
}
pwr_stop() rt_ini -s &>/dev/null
{ # Sleep until process is gone
create_wrapper while kill -0 $PID &>/dev/null; do
if [ `whoami` == "pwrp" ];then sleep 1
$wrapper -s done
if [ -e $pwrp_exe/pwrp_stop.sh ]; then
source $pwrp_exe/pwrp_stop.sh # Did we manage to bring everything down correct? Check to see if there are IPCs still left for the process
fi if [ ! -z $PID ]; then
else ipcs -p | grep $PID &>/dev/null
sudo -u pwrp $wrapper -s if [ $? -eq 0 ]; then
if [ -e $pwrp_exe/pwrp_stop.sh ]; then echo ""
sudo -u pwrp source $pwrp_exe/pwrp_stop.sh log_daemon_msg "IPC objects still present (abnormal termination of ProviewR?) running kill script" "rt_ini"
fi . $pwr_exe/pwr_stop.sh &>/dev/null
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 fi
}
pwr_kill() # 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
create_killer if [ $? -eq 0 ]; then
if [ `whoami` == "pwrp" ];then echo "\n"
$killer log_daemon_msg "Temporary files still present (abnormal termination of ProviewR?) running kill script" "rt_ini"
else . $pwr_exe/pwr_stop.sh &>/dev/null
sudo -u pwrp $killer
fi fi
}
case "$1" log_end_msg $?
in rm -f $LOCKFILE
start)
echo "Start Proview Runtime Environment."
pwr_start
echo "Done."
;;
stop)
echo "Stop Proveiw Runtime Environment."
pwr_stop
echo "Done."
;; ;;
restart) restart)
echo "Restart Proview Runtime Environment." $0 stop && sleep 2 && $0 start
echo "Closing down..."
pwr_stop
sleep 1
echo "Starting..."
pwr_start
echo "Done."
;; ;;
reload) try-restart)
echo "Reload Proview Runtime Environment" if $0 status >/dev/null; then
pwr_reload $0 restart
echo "Done." else
exit 0
fi
;; ;;
kill) reload)
echo "Remove all processes and resources for Proview Runtime Environment" PID=0
pwr_kill if [ -e $PIDFILE ]; then
echo "Done." 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
;; ;;
reset) status)
echo "Remove all processes and resources for Proview Runtime Environment" status_of_proc $DAEMON "ProviewR Runtime"
pwr_kill
echo "Done."
;; ;;
*) *)
echo " pwr Start and stop Proview Runtime Environment" >&2 echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
echo "" >&2 exit 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 esac
exit 0
[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="" bus_id=""
if [ -e /etc/proview.cnf ]; then if [ -e /etc/proview.cnf ]; then
bus_id=`eval cat /etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'` bus_id=`eval cat /etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'`
...@@ -20,10 +19,20 @@ export pwr_load=$pwrb_root/load ...@@ -20,10 +19,20 @@ export pwr_load=$pwrb_root/load
export pwr_lis=$pwrb_root/lis export pwr_lis=$pwrb_root/lis
export pwr_doc=$pwrb_root/doc export pwr_doc=$pwrb_root/doc
export pwrp_exe=$pwrp_root/x86_64_linux/exe # Fetch arch
export pwrp_lib=$pwrp_root/x86_64_linux/lib if [ -e /pwrp ]; then
export pwrp_obj=$pwrp_root/x86_64_linux/obj for dir in `ls -1 /pwrp`; do
export pwrp_lis=$pwrp_root/x86_64_linux/lis [[ "${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_inc=$pwrp_root/common/inc
export pwrp_load=$pwrp_root/common/load export pwrp_load=$pwrp_root/common/load
export pwrp_log=$pwrp_root/common/log export pwrp_log=$pwrp_root/common/log
...@@ -32,19 +41,19 @@ export pwrp_web=$web_dir ...@@ -32,19 +41,19 @@ export pwrp_web=$web_dir
export pwra_db=/usr/pwrp/adm/db 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` jdk=`eval ls -1 /usr/local | sort -r | grep ^jdk | head -1`
# Check if any JRE is present in /usr/local # Check if any JRE is present in /usr/local
if [ -z "$jdk" ]; then if [ -z "$jdk" ]; then
jdk=`eval ls -1 /usr/local | sort -r | grep ^jre | head -1` jdk=`eval ls -1 /usr/local | sort -r | grep ^jre | head -1`
fi 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 # 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 [ -z "$jdk" ]; then
if [ -e /usr/lib/jvm/default-java ]; then if [ -e /usr/lib/jvm/default-java ]; then
jdk=`eval realpath -qe /usr/lib/jvm/default-java` 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_name=`eval ls -1 /usr/lib/jvm | sort -r | grep ^java | head -1`
jdk=`eval realpath -qe /usr/lib/jvm/$jdk_name` jdk=`eval realpath -qe /usr/lib/jvm/$jdk_name`
unset jdk_name unset jdk_name
...@@ -64,11 +73,12 @@ fi ...@@ -64,11 +73,12 @@ fi
PATH=$PATH:$pwr_exe:$pwrp_exe:$jdk_home PATH=$PATH:$pwr_exe:$pwrp_exe:$jdk_home
#symbols to define start/stop commands for PWR #symbols to define start/stop commands for PWR
alias pwr_stop='/etc/init.d/pwr stop' alias pwr_stop='pwr stop'
alias pwr_stop.sh="/etc/init.d/pwr stop" alias pwr_start="pwr start"
alias pwr_start="/etc/init.d/pwr start"
alias pwr="/etc/init.d/pwr" pwr() {
alias boot="/usr/bin/sudo /sbin/reboot" systemctl "$1" pwr.service
}
if [ -e $pwrp_exe/profile ]; then if [ -e $pwrp_exe/profile ]; then
source $pwrp_exe/profile 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