postinst 6 KB
Newer Older
claes's avatar
claes committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/bash
set -e
if [ "$pwrrt_xtrace" != "" ]; then
  set -o xtrace
fi

# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
        if [ -d /usr/doc -a ! -e /usr/doc/pwrtest -a -d /usr/share/doc/pwrtest ]; then
                ln -sf ../share/doc/pwrtest /usr/doc/pwrtest
        fi
fi
# End automatically added section

proot="/pwrp"
aroot="/usr/pwrp/adm"

# Create users...
new_user=0
20 21 22 23 24 25
if getent group pwrp > /dev/null; then
  echo "-- group pwrp already exist"
else
  if groupadd pwrp; then
    echo "-- group pwrp added"
  fi
claes's avatar
claes committed
26
fi
27 28 29 30 31 32 33

if getent group b55 > /dev/null; then
  echo "-- group b55 already exist"
else
  if groupadd b55; then
    echo "-- group b55 added"
  fi
claes's avatar
claes committed
34
fi
35 36 37 38 39 40 41

if getent group b66 > /dev/null; then
  echo "-- group b66 already exist"
else
  if groupadd b66; then
    echo "-- group b66 added"
  fi
claes's avatar
claes committed
42
fi
43 44 45 46 47 48 49

if getent group skiftel > /dev/null; then
  echo "-- group skiftel already exist"
else
  if groupadd skiftel; then
    echo "-- group skiftel added"
  fi
claes's avatar
claes committed
50 51
fi

52 53 54 55 56


if getent passwd pwrp > /dev/null; then
  echo "-- user pwrp already exist"
else
claes's avatar
claes committed
57
  new_user=1
58 59 60 61

  if useradd -s /bin/bash -p aaupl/kQs1p3U -g pwrp -G b55,b66,skiftel -d /home/pwrp pwrp; then
    echo "-- user pwrp added"
  fi
claes's avatar
claes committed
62 63
  if [ ! -e /home/pwrp ]; then
    mkdir /home/pwrp
64 65 66 67 68 69 70 71 72 73 74
    cp /usr/pwrsev/cnf/user/.bashrc /home/pwrp
    cp /usr/pwrsev/cnf/user/.bash_profile /home/pwrp
    cp /usr/pwrsev/cnf/user/.mwmrc /home/pwrp
    cp /usr/pwrsev/cnf/user/.rtt_start /home/pwrp
    chmod a+x /home/pwrp/.rtt_start
    cp /usr/pwrsev/cnf/user/.xtt_start /home/pwrp
    chmod a+x /home/pwrp/.xtt_start
    cp /usr/pwrsev/cnf/user/.xsession /home/pwrp

    chown -R pwrp /home/pwrp
    chgrp -R pwrp /home/pwrp
claes's avatar
claes committed
75 76 77
  fi

  # Add to group dialout
78
  if getent group dialout > /dev/null; then
claes's avatar
claes committed
79 80 81 82
    usermod -a -G dialout pwrp
  fi
fi

83 84 85
if getent passwd skiftel > /dev/null; then
  echo "-- user skiftel already exist"
else
claes's avatar
claes committed
86
  new_user=1
87 88 89 90 91

  if useradd -s /bin/bash -p aa6NzxS/aBgP6 -g skiftel -G pwrp -d /home/skiftel skiftel; then
    echo "-- user skiftel added"
  fi

claes's avatar
claes committed
92 93
  if [ ! -e /home/skiftel ]; then
    mkdir /home/skiftel
94 95 96 97
    cp /usr/pwrsev/cnf/user/.bashrc /home/skiftel
    cp /usr/pwrsev/cnf/user/.bash_profile /home/skiftel
    cp /usr/pwrsev/cnf/user/.mwmrc /home/skiftel
    cp /usr/pwrsev/cnf/user/.rtt_start /home/skiftel
claes's avatar
claes committed
98
    chmod a+x /home/skiftel/.rtt_start
99
    cp /usr/pwrsev/cnf/user/.xtt_start /home/skiftel
claes's avatar
claes committed
100
    chmod a+x /home/skiftel/.xtt_start
101
    cp /usr/pwrsev/cnf/user/.xsession /home/skiftel
claes's avatar
claes committed
102 103 104 105 106 107

    chown -R pwrp /home/skiftel
    chgrp -R pwrp /home/skiftel
  fi
fi

108
if getent passwd b55 > /dev/null; then
claes's avatar
claes committed
109 110 111
  new_user=1

  # Check if group audio exist
112
  if getent group audio > /dev/null; then
claes's avatar
claes committed
113 114 115 116
    groups="pwrp,audio"
  else
    groups="pwrp"
  fi
117 118 119 120

  if useradd -s /bin/bash -p aaQPClsglxJP6 -g b55 -G $groups -d /home/b55 b55; then
    echo "-- user b55 added"
  fi
claes's avatar
claes committed
121 122
  if [ ! -e /home/b55 ]; then
    mkdir /home/b55
123 124 125 126
    cp /usr/pwrsev/cnf/op/.bashrc /home/b55
    cp /usr/pwrsev/cnf/op/.bash_profile /home/b55
    cp /usr/pwrsev/cnf/op/.mwmrc /home/b55
    cp /usr/pwrsev/cnf/op/.rtt_start /home/b55
claes's avatar
claes committed
127
    chmod a+x /home/b55/.rtt_start
128
    cp /usr/pwrsev/cnf/op/.xtt_start /home/b55
claes's avatar
claes committed
129
    chmod a+x /home/b55/.xtt_start
130
    cp /usr/pwrsev/cnf/op/.xsession /home/b55
claes's avatar
claes committed
131 132 133 134 135 136 137

    chown -R b55 /home/b55
    chgrp -R pwrp /home/b55
    chmod g+rwx /home/b55
  fi
fi

138
if getent passwd b66 > /dev/null; then
claes's avatar
claes committed
139 140 141
  new_user=1

  # Check if group audio exist
142 143
  if getent group audio > /dev/null; then
    groups="pwrp,audio"
claes's avatar
claes committed
144
  else
145 146 147 148 149
    groups="pwrp"
  fi

  if useradd -s /bin/bash -p aae.nHgHbfUpw -g b66 -G $groups -d /home/b66 b66; then
    echo "-- user b66 added"
claes's avatar
claes committed
150 151 152
  fi
  if [ ! -e /home/b66 ]; then
    mkdir /home/b66
153 154 155 156
    cp /usr/pwrsev/cnf/op/.bashrc /home/b66
    cp /usr/pwrsev/cnf/op/.bash_profile /home/b66
    cp /usr/pwrsev/cnf/op/.mwmrc /home/b66
    cp /usr/pwrsev/cnf/op/.rtt_start /home/b66
claes's avatar
claes committed
157
    chmod a+x /home/b66/.rtt_start
158
    cp /usr/pwrsev/cnf/op/.xtt_start /home/b66
claes's avatar
claes committed
159
    chmod a+x /home/b66/.xtt_start
160
    cp /usr/pwrsev/cnf/op/.xsession /home/b66
claes's avatar
claes committed
161 162 163 164 165 166 167

    chown -R b66 /home/b66
    chgrp -R pwrp /home/b66
    chmod g+rwx /home/b66
  fi
fi

168 169
chown -R pwrp /usr/pwrsev
chgrp -R pwrp /usr/pwrsev
claes's avatar
claes committed
170

171 172 173
chmod u+s /usr/pwrsev/exe/sev_ini
chown root /usr/pwrsev/exe/rt_prio
chmod u+s /usr/pwrsev/exe/rt_prio
claes's avatar
claes committed
174 175 176 177

# Copy configuration files
new_cnf=0
if [ ! -e /etc/proview.cnf ]; then
178
  cp /usr/pwrsev/cnf/proview.cnf /etc
claes's avatar
claes committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
  new_cnf=1
fi

# Add pwrp_profile to profile
if ! grep -q "/etc/pwrp_profile\b" /etc/profile; then
  cat >> /etc/profile <<-EOF
	if [ -e /etc/pwrp_profile ]; then
	  source /etc/pwrp_profile
	fi
EOF
fi

# Create startup link
set +e
checklink=`eval ls /etc/rc2.d/S90pwrsev 2>/dev/null`
set -e
if [ "$checklink" != "" ]; then
  rm /etc/rc2.d/S90pwrsev
fi
ln -s /etc/init.d/pwrsev /etc/rc2.d/S90pwrsev

# Create project
new_project=0
if [ ! -e $proot ]; then
  new_project=1

  mkdir $proot
  mkdir $proot/common
  mkdir $proot/common/inc
  mkdir $proot/common/load
  mkdir $proot/common/log
  mkdir $proot/common/loghist
  mkdir $proot/common/db
  mkdir $proot/common/web
  mkdir $proot/x86_linux
  mkdir $proot/x86_linux/exe
  mkdir $proot/x86_linux/lib
  mkdir $proot/x86_linux/obj
  mkdir $proot/x86_linux/lis

  chown -R pwrp $proot
  chgrp -R pwrp $proot
  
fi

if [ ! -e $aroot/db ]; then
  mkdir -p $aroot/db
  chown -R pwrp $aroot
fi

#

changes=0
if [ $new_user -eq 1 ]; then
  changes=1
elif [ $new_cnf -eq 1 ]; then
  changes=1
elif [ $new_project -eq 1 ]; then
  changes=1
fi

if [ $changes -ne 0 ]; then
  echo ""
  echo ""
  echo "***********************************************************"
  echo "  Don't forget to do this :"
  echo ""
fi

if [ $new_cnf -eq 1 ]; then
  echo "-- Enter QcomBusId in /etc/proview.cnf"
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
  nodename=`eval uname -n`
  echo "-- Create file /home/pwrp/.rhosts"
  echo "-- Distribute project to $nodename"
fi

if [ $changes -ne 0 ]; then
  echo ""
  echo "***********************************************************"
  echo ""
fi