File: install.sh

package info (click to toggle)
nut 2.8.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,356 kB
  • sloc: ansic: 123,904; sh: 14,718; cpp: 12,558; makefile: 5,212; python: 1,114; perl: 855; xml: 47
file content (1912 lines) | stat: -rwxr-xr-x 42,887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
#!/bin/sh
#	install.sh
#	Copyright (c) 2013-2016, by Eaton (R) Corporation. All rights reserved.
#	A shell script which installs IPP - Unix
#	It installs the native package then runs NUT configuration tools
#	to create an initial configuration and finally run the service.
. ./version.sh

PATH="$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin:/usr/xpg4/bin:/usr/xpg6/bin"
export PATH


NUT_PACKAGE_SOLARI="NUT_solaris_sparc_package2.6.5.local"
NUT_PACKAGE_SOLINT="NUT_solaris_i386_package2.6.5.local"

COMMON_DIR="common"
LOG_FILE=install.log
[ x"${IPP_DEBUG-}" = xyes ] || IPP_DEBUG=no
[ x"${IPP_WIPE_OLD_CONFIG-}" = xyes ] || IPP_WIPE_OLD_CONFIG=no

#configuration data
C_MODE="standalone"
C_HOSTNAME="localhost"
C_DEVICE=""
C_OPTION=""
C_NUM_DEV=0
C_PASSWORD=""
# Number of seconds for late emergency shutdown, goes into netxml-ups
# to get alerts from the UPS when battery runs low, *and* becomes the
# DELAY setting in ipp.conf used to power-cycle the UPSes in the end.
C_SHUTDOWN_DURATION="120"
# Number of minutes spent ONBATT for early-shutdown, goes into ipp.conf
# This logically matches the netxml-ups "shutdown_timer" parameter
# which is exclusive to this one driver and does not always work.
C_SHUTDOWN_TIMER="-1"
C_MINSUPPLIES=1
C_COMMUNITY="public"
C_NUM_NETWORK_DEVICE=0
# empty for automatic, "forbid" or "enforce" for once-and-for-all
C_POWERDOWNFLAG_USER=""

FIRST_IP=""
LAST_IP=""
NUT_PORT="3493"

ADMIN_FILE="/tmp/ipp_admin_file"

cd "`dirname $0`"

. "$COMMON_DIR/string.sh"

get_parameters() {
	case $1 in
	English)
		lang=EN
		;;
#	Japanese)
#		lang=JP
#		;;
	SOLARI)
		SYSTEM=$1
		;;
	SOLINT)
		SYSTEM=$1
		;;
	HPUX)
		SYSTEM=$1
		;;
	AIX)
		SYSTEM=$1
		;;
	esac
}

check_locale_language() {
	set `locale` >/dev/null 2>&1
	case $1 in
	LANG=en_US)
		lang=EN
		;;
	LANG=C)
		lang=EN
		;;
	esac
}

compute_SYSTEM () {
	set `uname -a`
	case "$1" in
	SunOS)
		case "$3" in
		5.*)
			case "$5" in
			i86pc)
				SYSTEM=SOLINT
				;;
			*)
				SYSTEM=SOLARI
				;;
			esac
		;;
		*)
			SYSTEM="Unknown System"
			;;
		esac
		;;
	HP-UX)
		SYSTEM=HPUX
		;;
	AIX)
		case "$4" in
		6)
			SYSTEM=AIX
			;;
		7)
			SYSTEM=AIX
			;;
		*)
			SYSTEM="This AIX version is not supported"
		;;
		esac
		;;
	*)
		SYSTEM="Unknown System"
		;;
	esac

	compute_system
}

compute_system () {
	case "$SYSTEM" in
	SOLINT)
		system=solint
		COMMON_DIR_SYS=solcmn
		;;
	SOLARI)
		system=solari
		COMMON_DIR_SYS=solcmn
		;;
	HPUX)
		system=hpux
		COMMON_DIR_SYS="$system"
		;;
	AIX)
		system=aix
		COMMON_DIR_SYS="$system"
		;;
	*)
		echo
		necho $ERR_UNKNOWN_SYS_STR1
		necho $ERR_UNKNOWN_SYS_STR2
#		echo "Valid systems are tagged SOLINT SOLARI HPUX AIX"
		necho $ERR_UNKNOWN_SYS_STR3
		echo
		necho $INSTALL_ERROR
		exit 1
		;;
	esac
}

read_def () {
	default="$2"

	if [ "$2" = "" ]; then
		necho "$1"
	else
		necho "$1" "[" "$2" "]"
	fi

	read answer
	if [ -z "$answer" ]; then
		answer="$default"
	fi
}

read_def_silent () {
	default="$2"

	necho $1
	stty -echo
	read answer
	stty echo
	if [ -z "$answer" ]; then
		answer="$default"
	fi
}

create_admin_file () {
	echo basedir=default > "$ADMIN_FILE"
	echo runlevel=quit >> "$ADMIN_FILE"
	echo conflict=nocheck >> "$ADMIN_FILE"
	echo setuid=nocheck >> "$ADMIN_FILE"
	echo action=nocheck >> "$ADMIN_FILE"
	echo partial=nocheck >> "$ADMIN_FILE"
	echo instance=overwrite >> "$ADMIN_FILE"
	echo idepend=quit >> "$ADMIN_FILE"
	echo rdepend=quit >> "$ADMIN_FILE"
	echo space=quit >> "$ADMIN_FILE"
}

install_files () {
	echo
	case "$LOG_FILE" in
		/*) ;;
		*)  LOG_FILE="`pwd`/$LOG_FILE" ;;
	esac
	rm -f "$LOG_FILE" > /dev/null 2>&1
	touch "$LOG_FILE"

	echo "NOTE: progress of this script's interpretation (and errors) will be logged into"
	echo "      $LOG_FILE"
	echo "      You should attach it to support calls should any problems arise"
	exec 2>"$LOG_FILE"
	echo "Started at `date` as: $0 $*" >&2
	set >&2
	set -x

	. ./uninstall-lsnw.sh
	# Check if Lansafe is installed
	detect_lansafe
	if [ $? -eq 0 ]; then
		necho $CS_REMOVE_LS
		# Proceed to uninstallation
		uninstall_lansafe
	fi

	# Check if Netwatch is installed
	detect_netwatch
	if [ $? -eq 0 ]; then
		necho $CS_REMOVE_NW
		# Proceed to uninstallation
		uninstall_netwatch
	fi

	# Clean-up previous installation
	remove_profile_settings
	if [ -d "/var/state/ups" ]; then
		rm -rf "/var/state/ups"
	fi
	if [ -d "/var/run/nut" ]; then
		rm -rf "/var/run/nut"
	fi
	if [ -d "$instpath/etc" ]; then
		cp -prf "$instpath/etc" "$instpath/etc.bak-$$"
		if [ x"${IPP_WIPE_OLD_CONFIG}" = xyes ]; then
			echo "Removing old configs because IPP_WIPE_OLD_CONFIG=yes"
			rm -rf "$instpath/etc"
		fi
	fi
	if [ -d "$instpath/xbin" ]; then
		rm -rf "$instpath/xbin"
	fi
	if [ -x "$instpath/bin/uninstall-ipp" ]; then
		necho $CS_REMOVE_OLDIPP
		"$instpath/bin/uninstall-ipp" || true
	fi
	if [ -e "$instpath/bin/ipp-wrapper" ]; then
		rm -f "$instpath/bin/ipp-wrapper" || true
	fi

	case "$system" in
	solari)
		necho $REMOVE_PACKAGE | tee -a "$LOG_FILE"

		create_admin_file

		pkgrm -n -a "$ADMIN_FILE" NUT >> "$LOG_FILE" 2>&1
		necho $INSTALL_PACKAGE | tee -a "$LOG_FILE"
		pkgadd -a "$ADMIN_FILE" -n \
			-d "$systemdir/$NUT_PACKAGE_SOLARI" NUT \
			>> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		rm -f "$ADMIN_FILE"
		# Modified initscript, to run upsmon as full root,
		# for optional early-shutdown support
		if [ -s "$COMMON_DIR_SYS/solaris_init" ]; then
			cp -f "$COMMON_DIR_SYS/solaris_init" "$instpath/nut"
			res=$?
			if [ ! $res = 0 ]; then
				necho $INSTALL_ERROR
				exit 1
			fi
		fi
		chown root:ipp "$instpath/nut" >> "$LOG_FILE" 2>&1 && \
		chmod 755 "$instpath/nut" >> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		rm -f /etc/init.d/nut /etc/rc3.d/K100nut /etc/rc3.d/S100nut /etc/rc3.d/S99nut /etc/rc0.d/K60nut
		ln -s "../../$instpath/nut" /etc/init.d/nut && \
		ln -s "../init.d/nut" /etc/rc3.d/S99nut && \
		ln -s "../init.d/nut" /etc/rc0.d/K60nut
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
	;;
	solint)
		necho $REMOVE_PACKAGE | tee -a "$LOG_FILE"

		create_admin_file

		pkgrm -n -a "$ADMIN_FILE" NUT >> "$LOG_FILE" 2>&1
		necho $INSTALL_PACKAGE | tee -a "$LOG_FILE"
		pkgadd -a "$ADMIN_FILE" -n \
			-d "$systemdir/$NUT_PACKAGE_SOLINT" NUT \
			>> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		rm -f "$ADMIN_FILE"
		# Modified initscript, to run upsmon as full root,
		# for optional early-shutdown support
		if [ -s "$COMMON_DIR_SYS/solaris_init" ]; then
			cp -f "$COMMON_DIR_SYS/solaris_init" "$instpath/nut"
			res=$?
			if [ ! $res = 0 ]; then
				necho $INSTALL_ERROR
				exit 1
			fi
		fi
		chown root:ipp "$instpath/nut" >> "$LOG_FILE" 2>&1 && \
		chmod 755 "$instpath/nut" >> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		rm -f /etc/init.d/nut /etc/rc3.d/K100nut /etc/rc3.d/S100nut /etc/rc3.d/S99nut /etc/rc0.d/K60nut
		ln -s "../../$instpath/nut" /etc/init.d/nut && \
		ln -s "../init.d/nut" /etc/rc3.d/S99nut && \
		ln -s "../init.d/nut" /etc/rc0.d/K60nut
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
	;;
	hpux)
		cd "$systemdir"
		rm -f nut.depot.tar > /dev/null 2>&1
		rm -Rf nut.depot > /dev/null 2>&1
		gunzip nut.depot.tar.gz >> "../$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			cd ..
			necho $INSTALL_ERROR
			exit 1
		fi
		tar xvf nut.depot.tar >> "../$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			cd ..
			necho $INSTALL_ERROR
			exit 1
		fi
		cd ..
		necho $REMOVE_PACKAGE | tee -a "$LOG_FILE"
		remove_hpux_upsmon_esd_support
		swremove NUT >> "$LOG_FILE" 2>&1
		necho $INSTALL_PACKAGE | tee -a "$LOG_FILE"
		swinstall -s "`pwd`/$systemdir/nut.depot/" NUT \
			>> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		add_hpux_upsmon_esd_support
	;;
	aix)
		necho $REMOVE_PACKAGE | tee -a "$LOG_FILE"
		rm -rf "$instpath/share/man" >> "$LOG_FILE" 2>&1
		rpm -e nut >> "$LOG_FILE" 2>&1
		rpm -e nut-client >> "$LOG_FILE" 2>&1
		necho $INSTALL_PACKAGE | tee -a "$LOG_FILE"
		rpm -i --nodeps `ls "$systemdir"/nut-*.aix6.1.ppc.rpm | grep -v 'nut-client'` \
			>> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		rpm -i --nodeps "$systemdir/"nut-client-*.aix6.1.ppc.rpm \
			>> "$LOG_FILE" 2>&1
		res=$?
		if [ ! $res = 0 ]; then
			necho $INSTALL_ERROR
			exit 1
		fi
		# Modified initscript, to run upsmon as full root,
		# for optional early-shutdown support
		if [ -s "$COMMON_DIR_SYS/aix_init" ]; then
			cp -f "$COMMON_DIR_SYS/aix_init" /etc/rc.d/init.d/ups
			res=$?
			chown root:ipp "/etc/rc.d/init.d/ups" >> "$LOG_FILE" 2>&1
			chmod 755 "/etc/rc.d/init.d/ups" >> "$LOG_FILE" 2>&1
			if [ ! $res = 0 ]; then
				necho $INSTALL_ERROR
				exit 1
			fi
		fi
		if [ ! -d "$instpath/share/man" ]; then
			for N in 1 3 5 8 ; do
				mkdir -p "$instpath/share/man/man$N" && \
				( cd "$instpath/share/man/man$N" && { \
					ln -s ../../../man/man$N/*.$N .
					ln -s ../../doc/nut-*/docs/man/*.$N . 2>/dev/null
				  } ; )
			done >> "$LOG_FILE" 2>&1
		fi
	;;

	*)
		necho $INSTALL_ERROR
		exit 1
	;;
	esac

	#ipp-wrapper goes first of custom files, to symlink against just
	# the packaged binaries - an action which we do first of all
	mkdir "$instpath/xbin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/xbin" >> "$LOG_FILE" 2>&1
	chmod 755 "$instpath/xbin" >> "$LOG_FILE" 2>&1
	( cd "$instpath/bin" && for F in * ; do
		if [ -f "$F" ] && [ ! -d "$F" ] && [ -x "$F" ] ; then
			ln -s "../bin/ipp-wrapper" "../xbin/$F"
		fi
	  done )
	( cd "$instpath/sbin" && for F in * ; do
		if [ -f "$F" ] && [ ! -d "$F" ] && [ -x "$F" ] && [ ! -x "../xbin/$F" ] ; then
			ln -s "../bin/ipp-wrapper" "../xbin/$F"
		fi
	  done )
	cp "$COMMON_DIR/ipp-wrapper" "$instpath/bin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/bin/ipp-wrapper" >> "$LOG_FILE" 2>&1
	chmod 755 "$instpath/bin/ipp-wrapper" >> "$LOG_FILE" 2>&1

	#install additional libraries
	cp "$systemdir/libs/"* "$instpath/lib" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/lib/*" >> "$LOG_FILE" 2>&1

	#powercycle-setting scripts
	cp "$COMMON_DIR/init" "$instpath" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/init" >> "$LOG_FILE" 2>&1
	chmod 744 "$instpath/init" >> "$LOG_FILE" 2>&1
	cp "$COMMON_DIR/shutdown" "$instpath" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/shutdown" >> "$LOG_FILE" 2>&1
	chmod 744 "$instpath/shutdown" >> "$LOG_FILE" 2>&1

	#OS shutdown script
	cp "$COMMON_DIR/ipp-os-shutdown" "$instpath/sbin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/sbin/ipp-os-shutdown" >> "$LOG_FILE" 2>&1
	chmod 744 "$instpath/sbin/ipp-os-shutdown" >> "$LOG_FILE" 2>&1

	# Config file with parameters for the shutdown program
	cp -f "$COMMON_DIR_SYS/ipp-os-shutdown.conf.sample" "$instpath/etc"
	if [ ! -s "$instpath/etc/ipp-os-shutdown.conf" ]; then
		cp -f "$instpath/etc/ipp-os-shutdown.conf.sample" \
			"$instpath/etc/ipp-os-shutdown.conf" >> "$LOG_FILE" 2>&1
	fi
	chown root:ipp "$instpath/etc/ipp-os-shutdown.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/ipp-os-shutdown.conf" >> "$LOG_FILE" 2>&1

	#custom shutdown procedure script
	cp "$COMMON_DIR/ipp-host-shutdown.sample" "$instpath/sbin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/sbin/ipp-host-shutdown.sample" >> "$LOG_FILE" 2>&1
	chmod 644 "$instpath/sbin/ipp-host-shutdown.sample" >> "$LOG_FILE" 2>&1

	#notifier script
	cp "$COMMON_DIR/ipp-notifier.sh" "$instpath/bin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/bin/ipp-notifier.sh" >> "$LOG_FILE" 2>&1
	chmod 754 "$instpath/bin/ipp-notifier.sh" >> "$LOG_FILE" 2>&1

	#sensitive config file, including passwords
	cp -f "$COMMON_DIR/ipp.conf" "$instpath/etc/ipp.conf.sample" >> "$LOG_FILE" 2>&1
	if [ ! -s "$instpath/etc/ipp.conf" ]; then
		cp -f "$instpath/etc/ipp.conf.sample" "$instpath/etc/ipp.conf" >> "$LOG_FILE" 2>&1
	fi
	chown root:ipp "$instpath/etc/ipp.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/ipp.conf" >> "$LOG_FILE" 2>&1

	#uninstall-ipp
	cp uninstall-ipp "$instpath/bin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/bin/uninstall-ipp" >> "$LOG_FILE" 2>&1
	chmod 744 "$instpath/bin/uninstall-ipp" >> "$LOG_FILE" 2>&1
	cp "$COMMON_DIR/string.sh" "$instpath/share" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/share/string.sh" >> "$LOG_FILE" 2>&1
	chmod 644 "$instpath/share/string.sh" >> "$LOG_FILE" 2>&1
	cp "$COMMON_DIR"_$lang/install.res "$instpath/share" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/share/install.res" >> "$LOG_FILE" 2>&1
	chmod 644 "$instpath/share/install.res" >> "$LOG_FILE" 2>&1

	#ipp-status
	cp "$COMMON_DIR/ipp-status" "$instpath/bin" >> "$LOG_FILE" 2>&1
	chown root:ipp "$instpath/bin/ipp-status" >> "$LOG_FILE" 2>&1
	chmod 755 "$instpath/bin/ipp-status" >> "$LOG_FILE" 2>&1

}

#######################
# Configuration screens

initial_configure () {

	conf_ok=""
	while [ -z "$conf_ok" ]; do
		C_NUM_DEV=0
		choose_mode
		if [ $? = 1 ]; then
			review_conf
		fi
	done

	# Make sure configuration files are not world readable
	chown ipp:ipp "$instpath/etc/ups.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/ups.conf" >> "$LOG_FILE" 2>&1

	chown ipp:ipp "$instpath/etc/upsd.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/upsd.conf" >> "$LOG_FILE" 2>&1

	chown ipp:ipp "$instpath/etc/nut.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/nut.conf" >> "$LOG_FILE" 2>&1

	chown ipp:ipp "$instpath/etc/upsmon.conf" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/upsmon.conf" >> "$LOG_FILE" 2>&1

	chown ipp:ipp "$instpath/etc/upsd.users" >> "$LOG_FILE" 2>&1
	chmod 640 "$instpath/etc/upsd.users" >> "$LOG_FILE" 2>&1

	# Report the SHUTDOWNSCRIPT_CUSTOM value or that it is missing
	_VAR="`egrep '^[ \t]*SHUTDOWNSCRIPT_CUSTOM=' "$instpath/etc/ipp.conf" 2>/dev/null`" || CC_SHUTDOWNSCRIPT_CUSTOM=""
	if [ -n "${_VAR}" ] ; then
		_VAR="`echo "${_VAR}" | sed 's,^[ \t]*SHUTDOWNSCRIPT_CUSTOM=,,'`"
		_VAR="`echo "${_VAR}" | sed -e 's,^"\(.*\)"$,\1,g' -e "s,^\'\(.*\)\'$,\1,g"`"
		case "${_VAR}" in
			*NUT_DIR*) _VAR1="`egrep '^[^\#]*NUT_DIR=' "$instpath/etc/ipp.conf" 2>/dev/null`" \
				&& [ -n "${_VAR1}" ] && _VAR1="`eval $_VAR1 && echo "$NUT_DIR"`" && [ -n "${_VAR1}" ] \
				&& _VAR2="`NUT_DIR="${_VAR1}" ; eval echo "${_VAR}"`" \
				&& [ -n "${_VAR2}" ] && _VAR="${_VAR2}" ;;
		esac
		if [ -n "${_VAR}" ] && [ -s "${_VAR}" ] && [ -x "${_VAR}" ]; then
			echo "INFO: Your ipp.conf contains SHUTDOWNSCRIPT_CUSTOM='${_VAR}' which points to an executable file"
		else
			echo "WARNING: Your ipp.conf contains SHUTDOWNSCRIPT_CUSTOM='${_VAR}' which points to a missing or not executable file"
		fi
	else
		echo "WARNING: Your ipp.conf does not have a SHUTDOWNSCRIPT_CUSTOM set, you might want one"
	fi
	unset _VAR _VAR1 _VAR2
}

choose_network() {
	necho $CS_SEPARATOR_1
	necho $CS_NETWORK_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_NETWORK_2
	echo
	necho $CS_NETWORK_3
	necho $CS_NETWORK_4
	read_def $CS_NETWORK_5 "1"
	case "$answer" in
	[2])
		C_MODE="netserver"
		;;
	*)
		C_MODE="standalone"
		;;
	esac
}

display_device () {
	DISP_COUNTER=1

	while [ "$DISP_COUNTER" -le "$C_NUM_DEV" ]; do
		eval TMP=\$C_DEVICE"$DISP_COUNTER"
#		DEV_TYPE="`printf "${DISP_COUNTER}- $TMP" | awk   -F' ' '{print \$2}'`"
		DEV_CONF="`echo "$TMP" | awk   -F' ' '{print \$3}'`"
		echo " " "$DISP_COUNTER". "$DEV_TYPE" "$DEV_CONF"
		DISP_COUNTER="`expr $DISP_COUNTER + 1`"
	done
}

remove_ups () {
	if [ "$answer" -lt 1 ]; then
		necho $CS_REMOVE_UPS_2
		return
	fi
	if [ "$answer" -gt "$C_NUM_DEV" ]; then
		necho $CS_REMOVE_UPS_2
		return
	fi

	OLD_NUM_DEV="$C_NUM_DEV"
	C_NUM_DEV="`expr $C_NUM_DEV - 1`"
	if [ "$C_NUM_DEV" -ne 0 ]; then
		eval C_DEVICE$answer=\${C_DEVICE$OLD_NUM_DEV}
		eval C_OPTION$answer=\${C_OPTION$OLD_NUM_DEV}

	fi
}

#return 0 to go back
#return 1 to continue the configuration
#retuen 2 to add another UPS
manage_ups () {
	if [ "$C_NUM_DEV" = 0 ]; then
		return 0
	fi

	necho $CS_SEPARATOR_1
	necho $CS_ANOTHER_UPS_1
	necho $CS_SEPARATOR_1
	echo
	display_device
	echo
	necho $CS_ANOTHER_UPS_2
	necho $CS_ANOTHER_UPS_3
	necho $CS_ANOTHER_UPS_4
	necho $CS_ANOTHER_UPS_5
	read_def $CS_ANOTHER_UPS_6 "1"

	case "$answer" in
	[2])
		return 2
		;;
	[3])
		read_def $CS_REMOVE_UPS_1 ""
		remove_ups
		ret=""
		manage_ups
		ret=$?
		return $ret
		;;
	[0])
		return 0
		;;
	*)
		return 1
		;;
	esac
}

choose_mode() {
	necho $CS_SEPARATOR_1
	necho $CS_WELCOME_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_MANAGE_1
	echo
	necho $CS_MANAGE_2
	necho $CS_MANAGE_3
	read_def $CS_MANAGE_4 "1"
	case "$answer" in
	[2])
		necho $CS_SEPARATOR_1
		necho $CS_CLIENT_SD_DURATION_1
		necho $CS_SEPARATOR_1
		echo
		necho $CS_CLIENT_SD_DURATION_2
		read TMP

		choose_esd_timer

		C_MODE="netclient"
		ret=2
		while [ $ret = 2 ]; do
			choose_server
			manage_ups
			ret=$?
		done
		;;
	*)
		choose_shutdown_duration
		choose_esd_timer
		choose_network
		ret=2
		while [ $ret = 2 ]; do
			choose_connectivity
			manage_ups
			ret=$?
		done

		if [ $ret = 1 ]; then
			ret=""
			choose_password
			ret=$?
		fi

		if [ $C_NUM_DEV -gt 0 ]; then
			ret=""
			choose_static_powercycle
			ret=$?
		fi
		;;
	esac

	if [ $ret = 1 ]; then
		if [ $C_NUM_DEV -gt 1 ]; then
			ret=""
			choose_minsupplies
			ret=$?
		fi
	fi

	return $ret
}

choose_static_powercycle() {
	necho $CS_SEPARATOR_1
	necho $CS_STATIC_POWERCYCLE_1
	necho $CS_SEPARATOR_1

	answer="x"
	while [ "$answer" != "" ] && [ "$answer" != "forbid" ] && [ "$answer" != "enforce" ]; do
		read_def $CS_STATIC_POWERCYCLE_2 "$C_POWERDOWNFLAG_USER"
		#Check if this is a valid answer
		case "$answer" in
			[Ff]|[Ff][Oo][Rr][Bb][Ii][Dd]|[Nn]|[Nn][Oo])
				answer="forbid" ;;
			[Ee]|[Ee][Nn][Ff][Oo][Rr][Cc][Ee]|[Yy]|[Yy][Ee][Ss])
				answer="enforce" ;;
			""|[Aa][Uu][Tt][Oo])
				answer="" ;;
			*)
				necho $CS_ERR_BADSTRING
				answer="x" ;;
		esac
	done

	C_POWERDOWNFLAG_USER="$answer"
	return 1
}

choose_esd_timer() {
	necho $CS_SEPARATOR_1
	necho $CS_ESDTIMER_1
	necho $CS_SEPARATOR_1

	answer=""
	while [ "$answer" = "" ]; do
		read_def $CS_ESDTIMER_2 "$C_SHUTDOWN_TIMER"
		#Check if this is a valid number
		if [ "$answer" = "" ]; then answer="-1"; fi
		if echo "$answer" | egrep '^\-*[0-9]+$' > /dev/null 2>&1 ; then
			#this is a number
			if [ $answer -lt 0 ]; then
				answer="-1"
			fi
		else
			necho $CS_ERR_NO_NUM
			answer=""
		fi
	done

	C_SHUTDOWN_TIMER="$answer"

	return 1
}

choose_minsupplies() {
	necho $CS_SEPARATOR_1
	necho $CS_MINSUP_1
	necho $CS_SEPARATOR_1

	answer=""
	while [ "$answer" = "" ]; do
		read_def $CS_MINSUP_2 $C_NUM_DEV
		#Check if this is a valid number
		if echo "$answer" | egrep '^[0-9]+$' > /dev/null 2>&1 ; then
			#this is a number
			if [ $answer -lt 1 ]; then
				answer=""
			fi
		else
			necho $CS_ERR_NO_NUM
			answer=""
		fi
	done;

	C_MINSUPPLIES="$answer"
	if [ "$answer" -gt "$C_NUM_DEV" ]; then
		C_MINSUPPLIES="$C_NUM_DEV"
	fi

	return 1
}

choose_connectivity() {
	ret="0"
	while [ $ret = "0" ]; do
		necho $CS_SEPARATOR_1
		necho $CS_CONNECTIVITY_1
		necho $CS_SEPARATOR_1
		echo
		necho $CS_CONNECTIVITY_2
		necho $CS_CONNECTIVITY_3
		necho $CS_CONNECTIVITY_4
		read_def $CS_CONNECTIVITY_5 "1"
		case "$answer" in
		[0])
			return 0
			;;
		[2])
#TODO
			choose_xml_manual_or_auto
			ret=$?
			;;
		*)
			choose_ask_scan_serial
			ret=$?
			;;
		esac
	done
	return $ret
}

choose_ask_scan_serial() {
	ret="0"
	while [ $ret = "0" ]; do
		necho $CS_SEPARATOR_1
		necho $CS_ASK_SERIAL_1
		necho $CS_SEPARATOR_1
		echo
		necho $CS_ASK_SERIAL_2
		echo
		necho $CS_ASK_SERIAL_3
		necho $CS_ASK_SERIAL_4
		necho $CS_ASK_SERIAL_5
		read_def $CS_ASK_SERIAL_6 "1"
		case "$answer" in
		[0])
			return 0
			;;
		[2])
			choose_manual_serial
			ret=$?
			;;
		*)
			choose_serial
			ret=$?
			;;
		esac
	done
	return $ret
}

choose_serial() {
	serial_list="`$NUTCONF --scan-serial auto 2>> "$LOG_FILE"`"
	if [ x"$serial_list" = x"" ]; then
		echo
		read_def $CS_ERR_NO_SERIAL ""
		echo
		return 0
	fi

	necho $CS_SEPARATOR_1
	necho $CS_SERIAL_1
	necho $CS_SEPARATOR_1
	echo

	OLD1_IFS="$IFS"
	IFS="
"

	i="1"
	for s in $serial_list; do
		DEV_NAME="`echo "$s" | awk   -F' ' '{print \$3}'`"
		echo "                      $i. $DEV_NAME"
		i="`expr $i + 1`"
	done

	IFS="$OLD1_IFS"

	necho $CS_SERIAL_3
	read_def $CS_SERIAL_4 "1"
	case "$answer" in
	[0])
		return 0
		;;
	*)
		OLD1_IFS="$IFS"
		IFS="
"

		C_NUM_DEV="`expr $C_NUM_DEV + 1`"
		i="1"
		for s in $serial_list; do
			if [ "$i" = "$answer" ]; then
				eval C_DEVICE$C_NUM_DEV=\"$s\"
				eval C_OPTION$C_NUM_DEV=\"\"
				break;
			fi
			i="`expr $i + 1`"
		done
		IFS="$OLD1_IFS"
		;;
	esac

	return 1
}

choose_manual_serial () {
	necho $CS_SEPARATOR_1
	necho $CS_MANUAL_SERIAL_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_MANUAL_SERIAL_2
	read_def $CS_MANUAL_SERIAL_3 ""

	DEV="`$NUTCONF --scan-serial $answer 2>> "$LOG_FILE"`"

	if [ "$DEV" = "" ]; then
		read_def $CS_MANUAL_SERIAL_ERR ""
		return 0;
	fi

	C_NUM_DEV="`expr $C_NUM_DEV + 1`"
	eval C_DEVICE$C_NUM_DEV=$DEV

	return 1
}

choose_xml_manual_or_auto() {
	necho $CS_SEPARATOR_1
	necho $CS_XML_MANU_AUTO_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_XML_MANU_AUTO_2
	echo
	necho $CS_XML_MANU_AUTO_3
	necho $CS_XML_MANU_AUTO_4
	necho $CS_XML_MANU_AUTO_5

	read_def $CS_XML_MANU_AUTO_6 "1"
	case "$answer" in
	[2])
		choose_xml_manual
		return $?
		;;
	[0])
		return 0
		;;
	*)
		choose_xml
		return $?
	esac
}

choose_xml_manual() {
	necho $CS_SEPARATOR_1
	necho $CS_XML_MANU_1
	necho $CS_SEPARATOR_1
	echo
	read_def $CS_XML_MANU_2 ""

	if [ x"$answer" = x"" ]; then
		return 0
	fi

	C_NUM_DEV="`expr $C_NUM_DEV + 1`"
	eval C_DEVICE$C_NUM_DEV=\"XML netxml-ups http://$answer\"

	nmc_login
	return 1
}

choose_xml() {
	necho $CS_SEPARATOR_1
	necho $CS_SNMP_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_SNMP_2
	echo
	necho $CS_SNMP_6
	echo

	LIST_XML="`$NUTCONF --scan-xml-http 2>> "$LOG_FILE"`"
	if [ "$LIST_XML" = "" ]; then
		read_def $CS_SNMP_7 ""
		choose_snmp
		return $?
	fi

	LIST_XML="`echo "$LIST_XML" | sort`"

	echo

	OLD1_IFS="$IFS"
	IFS="
"

	i="1"
	for s in $LIST_XML; do
		#FIXME: If there is a comma in the description, the description
		#will be shown up to this comma only.
		IP_ADDR="`echo "$s" | awk   -F' ' '{print \$3}' | sed 's/http:\/\///g'`"
		#DESC="`echo "$s" | awk   -F\" '{print $6}' | sed -e "s/^.*\"\(.*\)\".*$/\1/"`"
		echo "                      $i. $IP_ADDR"
		i="`expr $i + 1`"
	done
	IFS="$OLD1_IFS"

	# Ask to scan for more UPS
	printf "                      $i. "
	necho $CS_SNMP_10
	necho $CS_SNMP_9

	read_def $CS_SNMP_8 "1"
	case "$answer" in
	"$i")
		choose_snmp
		return $?
		;;
	[0])
		return 0
		;;
	*)
		OLD1_IFS="$IFS"
		IFS="
"

		C_NUM_DEV="`expr $C_NUM_DEV + 1`"
		i="1"
		for s in $LIST_XML; do
			if [ "$i" = "$answer" ]; then
				eval C_DEVICE$C_NUM_DEV=\"$s\"
				nmc_login
				IFS=$OLD1_IFS
				return 1;
			fi
			i="`expr $i + 1`"
		done
		IFS="$OLD1_IFS"
		C_NUM_DEV="`expr $C_NUM_DEV - 1`"
		;;
	esac

	return 0
}

choose_snmp() {
	necho $CS_SEPARATOR_1
	necho $CS_SNMP_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_SNMP_2
	echo
	read_def $CS_SNMP_3 $FIRST_IP
	FIRST_IP="$answer"
	if [ "$answer" = "" ]; then
		return 0
	fi
	read_def $CS_SNMP_4 $LAST_IP
	LAST_IP="$answer"
	if [ "$answer" = "" ]; then
		LAST_IP="$FIRST_IP"
	fi

	echo
	read_def $CS_SNMP_5 $C_COMMUNITY
	C_COMMUNITY="$answer"

	echo
	necho $CS_SNMP_6
	echo

	list="`$NUTCONF --scan-snmp "$FIRST_IP" "$LAST_IP" community="$C_COMMUNITY" 2>> "$LOG_FILE"`"

	list="`echo "$list" | sort`"
	echo

	filter_snmp_list

	if [ "$LIST_SNMP" = "" ]; then
		read_def $CS_SNMP_7 ""
		return 0
	fi

	OLD1_IFS="$IFS"
	IFS="
"

	i="1"
	for s in $LIST_SNMP; do
		#FIXME: If there is a comma in the description, the description
		#will be shown up to this comma only.
		IP_ADDR="`echo "$s" | awk   -F' ' '{print \$3}'`"
		#DESC="`echo "$s" | awk   -F\" '{print $6}' | sed -e "s/^.*\"\(.*\)\".*$/\1/"`"
		echo "                      $i. $IP_ADDR"
		i="`expr $i + 1`"
	done
	IFS="$OLD1_IFS"

	necho $CS_SNMP_9

	read_def $CS_SNMP_8 "1"
	case "$answer" in
	[0])
		return 0
		;;
	*)
		OLD1_IFS="$IFS"
		IFS="
"

		C_NUM_DEV="`expr $C_NUM_DEV + 1`"
		i="1"
		for s in $LIST_SNMP; do
			if [ "$i" = "$answer" ]; then
				eval C_DEVICE$C_NUM_DEV=\"$s\"
				eval C_OPTION$C_NUM_DEV=\"community=$C_COMMUNITY\"
				IFS="$OLD1_IFS"
				return 1
			fi
			i="`expr $i + 1`"
		done
		IFS="$OLD1_IFS"
		C_NUM_DEV="`expr $C_NUM_DEV - 1`"
		;;
	esac

	return 0
}

#Remove XML devices from the SNMP list
filter_snmp_list() {
	LIST_SNMP=""
	OLD1_IFS="$IFS"
	IFS="
"
	for s in $list; do
		IP_SNMP="`echo "$s" | awk   -F' ' '{print \$3}'`"
		TO_ADD="$s"
		for x in $LIST_XML; do
			IP_XML="`echo "$x" | awk   -F' ' '{print \$3}' | sed 's/http:\/\///g'`"
			if [ "$IP_SNMP" = "$IP_XML" ]; then
				TO_ADD=""
				break
			fi
		done
		if [ ! "$TO_ADD" = "" ]; then
			LIST_SNMP="`echo "$LIST_SNMP";echo "$TO_ADD"`"
		fi
	done
	IFS="$OLD1_IFS"
}


#only used in netclient mode
choose_server() {
	necho $CS_SEPARATOR_1
	necho $CS_SERVER_1
	necho $CS_SEPARATOR_1
	echo
	necho $CS_SERVER_2
	echo
	read_def $CS_SERVER_3 ""
	FIRST_IP="$answer"
	if [ x"$answer" = x"" ]; then
		return 0
	fi
	read_def $CS_SERVER_4 ""
	LAST_IP="$answer"
	if [ x"$answer" = x"" ]; then
		LAST_IP=$FIRST_IP
	fi

	echo
	necho $CS_SERVER_5
	echo

	list="`$NUTCONF --scan-nut "$FIRST_IP" "$LAST_IP" "$NUT_PORT" 2>> "$LOG_FILE"`"
#TODO parse scan results
	if [ "$list" = "" ]; then
		read_def $CS_SERVER_6 ""
		return 0
	fi

	echo

	OLD1_IFS="$IFS"
	IFS="
"

	i="1"
	for s in $list; do
		UPS="`echo "$s" | awk   -F' ' '{print \$3}'`"
		echo "                      $i. $UPS"
		i="`expr $i + 1`"
	done
	IFS="$OLD1_IFS"

	necho $CS_SERVER_8

	read_def $CS_SERVER_7 "1"
	case "$answer" in
	[0])
		return 0
		;;
	*)
		echo "$C_NUM_DEV"
		C_NUM_DEV="`expr $C_NUM_DEV + 1`"
		echo "$C_NUM_DEV"
		i="1"
		OLD1_IFS="$IFS"
		IFS="
"
		for s in $list; do
			if [ "$i" = "$answer" ]; then
				eval C_DEVICE$C_NUM_DEV=\"$s\"
				eval C_OPTION$C_NUM_DEV=\"\"
				break
			fi
			i="`expr $i + 1`"
		done
		IFS="$OLD1_IFS"
		;;
	esac

	return 1
}

choose_password() {
	necho $CS_SEPARATOR_1
	necho $CS_PASSWORD_1
	necho $CS_SEPARATOR_1

	answer=""
	PASS1="1"
	while [ ! "$answer" = "$PASS1" ] || [ -z "$answer" ]; do
		read_def_silent $CS_PASSWORD_3 ""
		PASS1="$answer"
		read_def_silent $CS_PASSWORD_4 ""
		if [ ! "$answer" = "$PASS1" ]; then
			echo
			necho $CS_ERR_PASSWORDS_DIFFER
			echo
		fi
	done
	C_PASSWORD="$answer"

	return 1
}

get_networked_device() {
	NDEV=0
	C_NUM_NETWORK_DEVICE=0

	while [ "$NDEV" -lt "$C_NUM_DEV" ]; do
		NDEV="`expr $NDEV + 1`"
		eval TMP=\$C_DEVICE"$NDEV"
		DRIVER="`echo "$TMP" | awk -F' ' '{print \$2}'`"
		if [ "$DRIVER" = "netxml-ups" ]; then
			C_NUM_NETWORK_DEVICE="`expr $C_NUM_NETWORK_DEVICE + 1`"
		fi
	done
}

nmc_login() {
	necho $CS_SEPARATOR_1
	necho $CS_NMC_LOGIN_1
	necho $CS_SEPARATOR_1
	echo
	read_def $CS_NMC_LOGIN_2 "admin"
	NMC_LOGIN="$answer"
	answer=""
	PASS1="1"
	while [ ! "$answer" = "$PASS1" ]; do
		read_def_silent $CS_NMC_LOGIN_3 ""
		PASS1="$answer"
		read_def_silent $CS_NMC_LOGIN_4 ""
		if [ ! "$answer" = "$PASS1" ]; then
			echo
			necho $CS_ERR_PASSWORDS_DIFFER
			echo
		fi
	done
	ESD_NETXML_OPTION=""
	if [ "$C_SHUTDOWN_TIMER" -gt 0 ] 2>/dev/null; then
		# Note the leading space is included if value is set
		# Also note this is a cosmetic setting for NMC web-gui
		# to display the value, discrepancies that creep in
		# during later system administration are not sync'ed.
		ESD_NETXML_OPTION=" shutdown_timer=`expr $C_SHUTDOWN_TIMER \* 60`" || \
		ESD_NETXML_OPTION=""
	fi
	if [ "$C_SHUTDOWN_TIMER" -eq 0 ] 2>/dev/null; then
		# Some value >0 must be set to be picked up; for this
		# choice of "1 sec" the NMC Web-GUI shows "0 min" anyway
		ESD_NETXML_OPTION=" shutdown_timer=1"
	fi
	eval C_OPTION$C_NUM_DEV=\"login=$NMC_LOGIN password=$answer subscribe=yes$ESD_NETXML_OPTION shutdown_duration=$C_SHUTDOWN_DURATION\"
}

choose_shutdown_duration() {
	necho $CS_SEPARATOR_1
	necho $CS_SHUTOFF_DELAY_1
	necho $CS_SEPARATOR_1
	echo
	answer=""
	while [ "$answer" = "" ]; do
		read_def $CS_SHUTOFF_DELAY_3 "$C_SHUTDOWN_DURATION"
		#Check if this is a valid number
		if echo "$answer" | egrep '^[0-9]+$' > /dev/null 2>&1; then
			#this is a number, do nothing
			sleep 0
		else
			necho $CS_ERR_NO_NUM
			answer=""
		fi
	done;
	C_SHUTDOWN_DURATION="$answer"

	return 1
}

set_shutdown_command_legacy() {
	SHUTDOWN_CMD="$instpath/shutdown;/usr/sbin/shutdown"

	case "$system" in
	solari)
		$NUTCONF --set-shutdowncmd "$SHUTDOWN_CMD -y -g 0 -i 5" 2>> "$LOG_FILE"
		;;
	solint)
		$NUTCONF --set-shutdowncmd "$SHUTDOWN_CMD -y -g 0 -i 5" 2>> "$LOG_FILE"
		;;
	hpux)
		$NUTCONF --set-shutdowncmd "cd /;$SHUTDOWN_CMD -y -h now" 2>> "$LOG_FILE"
		;;
	aix)
		$NUTCONF --set-shutdowncmd "$SHUTDOWN_CMD -h +0" 2>> "$LOG_FILE"
		;;
	*)
		;;
	esac
}

set_shutdown_command() {
	if [ -x "$instpath/sbin/ipp-os-shutdown" ]; then
		# The new common logic is available, use it
		$NUTCONF --set-shutdowncmd "$instpath/sbin/ipp-os-shutdown -t now" 2>> "$LOG_FILE"
	else
		# Use old OS-specific snippets
		set_shutdown_command_legacy
	fi

	$NUTCONF --set-powerdownflag "$instpath/etc/killpower" 2>> "$LOG_FILE"
}

set_notify() {
	# Events messages (mc2/scripts/lang/eng.lbl)
	# '/Event/UPS.PowerSummary.PresentStatus.ACPresent/1'
	$NUTCONF --set-notifymsg ONLINE "The system is powered by the utility" 2>> "$LOG_FILE" # "UPS %s on line power"
	# '/Event/UPS.PowerSummary.PresentStatus.ACPresent/0'
	$NUTCONF --set-notifymsg ONBATT "The system is powered by the UPS battery" 2>> "$LOG_FILE" #"UPS %s on battery"
	# '/Event/UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit/1'
	$NUTCONF --set-notifymsg LOWBATT "Low battery alarm" 2>> "$LOG_FILE" # "UPS %s battery is low"
	# ?
	$NUTCONF --set-notifymsg FSD "UPS %s: forced shutdown in progress" 2>> "$LOG_FILE"
	# '/Event/System.CommunicationLost/0'
	$NUTCONF --set-notifymsg COMMOK "Communication with device is restored" 2>> "$LOG_FILE" # "Communications with UPS %s established"
	# '/Event/System.CommunicationLost/1'
	$NUTCONF --set-notifymsg COMMBAD "Communication with device has failed" 2>> "$LOG_FILE" # "Communications with UPS %s lost"
	# ?
	$NUTCONF --set-notifymsg SHUTDOWN "Auto logout and shutdown proceeding" 2>> "$LOG_FILE"
	# '/Event/UPS.PowerSummary.PresentStatus.NeedReplacement/1'
	$NUTCONF --set-notifymsg REPLBATT "Battery fault" 2>> "$LOG_FILE" # "UPS %s battery needs to be replaced"
	$NUTCONF --set-notifymsg NOCOMM "UPS %s is unavailable" 2>> "$LOG_FILE"
	$NUTCONF --set-notifymsg NOPARENT "Shutdown failure" 2>> "$LOG_FILE" # "upsmon parent process died - shutdown impossible"

	# Enable mail notification
	$NUTCONF --set-notifycmd "$instpath/bin/ipp-notifier.sh" 2>> "$LOG_FILE"

	$NUTCONF --set-notifyflags ONLINE EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags ONBATT EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags LOWBATT EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags FSD EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags COMMOK EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags COMMBAD EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags SHUTDOWN EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags REPLBATT EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags NOCOMM EXEC 2>> "$LOG_FILE"
	$NUTCONF --set-notifyflags NOPARENT EXEC 2>> "$LOG_FILE"
}

set_ippconf_value() {
	# Replaces a value in the installed ipp.conf which is an assignment
	# of "$1='$2'" and which is not a comment (optional whitespace may
	# be prepended in the present line, but will be removed in the end)
	egrep -v '^[ \t]*('"$1"')=' "$instpath/etc/ipp.conf" \
		> "$instpath/etc/ipp.conf.tmp" && \
	echo "$1='$2'" >> "$instpath/etc/ipp.conf.tmp" && \
	cat "$instpath/etc/ipp.conf.tmp" > "$instpath/etc/ipp.conf"
	res=$?
	rm -f "$instpath/etc/ipp.conf.tmp"
	return $res
}

set_shutdown_duration() {
	set_ippconf_value DELAY "$C_SHUTDOWN_DURATION"
	set_ippconf_value PASSWORD "$C_PASSWORD"
}

set_minsupplies() {
	$NUTCONF --set-minsupplies "$C_MINSUPPLIES" 2>> "$LOG_FILE"
}

set_debug_flag() {
	# Keep an old value if it was set
	egrep '^[ \t]*IPP_DEBUG=' "$instpath/etc/ipp.conf" >/dev/null || \
		echo "IPP_DEBUG='$IPP_DEBUG'" >> "$instpath/etc/ipp.conf"
}

set_esd_timer() {
	set_ippconf_value SHUTDOWN_TIMER "$C_SHUTDOWN_TIMER"
}

set_host_os_flavour() {
	set_ippconf_value HOST_OS_FLAVOUR "$system"
}

set_static_powercycle() {
	# Generally this variable should be left empty and the powercycling
	# would be enabled or diabled based on killpower flag. However in some
	# cases a user may want to enforce the setting (e.g. last ESD host).
	set_ippconf_value POWERDOWNFLAG_USER "$C_POWERDOWNFLAG_USER"
}

review_conf() {
	display_conf

	read_def $CS_REVIEW_10 "n"
	case "$answer" in
	[yY])
		conf_ok="ok"

		$NUTCONF --set-mode "$C_MODE" 2>> "$LOG_FILE"

		case "$C_MODE" in
		netclient)
			apply_conf_client
			;;
		netserver)
			apply_conf_server
			;;
		standalone)
			apply_conf_standalone
			;;
		esac

		set_minsupplies
		set_shutdown_command
		set_notify
		set_shutdown_duration
		set_esd_timer
		set_static_powercycle
		set_debug_flag

		;;

	*)
		;;
	esac

}

display_conf() {
	necho $CS_SEPARATOR_1
	necho $CS_REVIEW_1
	necho $CS_SEPARATOR_1
	echo
	if [ "$C_MODE" = "standalone" ]; then
		necho $CS_REVIEW_2
	fi
	if [ "$C_MODE" = "netserver" ]; then
		necho $CS_REVIEW_3
	fi
	if [ "$C_MODE" = "netclient" ]; then
		necho $CS_REVIEW_4
	fi
	echo
	necho $CS_REVIEW_5
	display_device
	echo
	if [ "$C_NUM_DEV" -gt 1 ]; then
		necho $CS_REVIEW_6 " " $C_MINSUPPLIES
	fi

	necho $CS_REVIEW_7 " " $C_SHUTDOWN_TIMER
	echo

	necho $CS_REVIEW_8 " " $C_SHUTDOWN_DURATION
	echo

	necho $CS_REVIEW_9 " " $C_POWERDOWNFLAG_USER
	echo

}

apply_conf_client() {
	NDEV=1
	$NUTCONF --set-user upsmon=slave password=upsmon 2>> "$LOG_FILE"

	eval TMP=\$C_DEVICE$NDEV
	DEV="`echo "$TMP" | awk -F' ' '{print \$3}'`"
	UPS="`echo "$DEV" | awk -F'@' '{print \$1}'`"
	HOST="`echo "$DEV"| awk -F'@' '{print \$2}'`"
	# TODO: Here we assume that one UPS powers one input of the server
	# Logically this can mismatch our setting of MINSUPPLIES if the user
	# (later) specifies real powersource counts, and topology is not 1:1
	$NUTCONF --set-monitor "${UPS}" "$HOST" 1 upsmon upsmon slave 2>> "$LOG_FILE"

	while [ "$NDEV" -lt "$C_NUM_DEV" ]; do
		NDEV="`expr $NDEV + 1`"
		eval TMP=\$C_DEVICE$NDEV
		DEV="`echo "$TMP" | awk -F' ' '{print \$3}'`"
		UPS="`echo "$DEV" | awk -F'@' '{print \$1}'`"
		HOST="`echo "$DEV"| awk -F'@' '{print \$2}'`"
		$NUTCONF --add-monitor "${UPS}" "$HOST" 1 upsmon upsmon slave 2>> "$LOG_FILE"
	done
}

split_device () {
	eval TMP=\$C_DEVICE$NDEV
	ID="`echo "$TMP" | awk -F' ' '{print \$1}'`"
	DRIVER="`echo "$TMP" | awk -F' ' '{print \$2}'`"
	PORT="`echo "$TMP" | awk -F' ' '{print \$3}'`"
}

setup_tty () {
	local TTY="$1" > "$LOG_FILE" 2>&1

	chmod 666 "$TTY" > "$LOG_FILE" 2>&1
	chown ipp:ipp "$TTY" > "$LOG_FILE" 2>&1
}

set_device_monitor_user () {
	NDEV=1

	split_device

	eval TMP=\$C_OPTION$NDEV
	$NUTCONF --set-device "${ID}$NDEV" "$DRIVER" "$PORT" $TMP 2>> "$LOG_FILE"
	$NUTCONF --set-monitor "${ID}$NDEV" localhost 1 upsmon upsmon master 2>> "$LOG_FILE"

	echo "$PORT" | grep '^/dev/tty' >/dev/null && setup_tty "$PORT"

	while [ "$NDEV" -lt "$C_NUM_DEV" ]; do
		NDEV="`expr $NDEV + 1`"
		split_device
		eval TMP=\$C_OPTION$NDEV
		$NUTCONF --add-device "${ID}$NDEV" "$DRIVER" "$PORT" $TMP 2>> "$LOG_FILE"
		$NUTCONF --add-monitor "${ID}$NDEV" localhost 1 upsmon upsmon master 2>> "$LOG_FILE"

		echo "$PORT" | grep '^/dev/tty' >/dev/null && setup_tty "$PORT"
	done

	$NUTCONF --set-user admin password="$C_PASSWORD" actions=SET instcmds=all 2>> "$LOG_FILE"
	$NUTCONF --add-user upsmon=master password=upsmon 2>> "$LOG_FILE"
}

apply_conf_server() {
	$NUTCONF --set-listen 0.0.0.0 2>> "$LOG_FILE"

	set_device_monitor_user
}

apply_conf_standalone () {
	$NUTCONF --set-listen 127.0.0.1 2>> "$LOG_FILE"

	set_device_monitor_user
}

start_service () {
	necho $CS_START_SERVICE
	stop_service
	case "$system" in
		solari)
		/etc/init.d/nut start >> "$LOG_FILE" 2>&1
		;;
		solint)
		/etc/init.d/nut start >> "$LOG_FILE" 2>&1
		;;
		hpux)
		/sbin/init.d/nut-drvctl start >> "$LOG_FILE" 2>&1
		/sbin/init.d/nut-upsd start >> "$LOG_FILE" 2>&1
		/sbin/init.d/nut-upsmon start >> "$LOG_FILE" 2>&1
		;;
		aix)
		/etc/rc.d/init.d/ups start >> "$LOG_FILE" 2>&1
		;;
		*)
		;;
	esac
}

stop_service () {
	case $system in
		solari)
		/etc/init.d/nut stop >> "$LOG_FILE" 2>&1
		;;
		solint)
		/etc/init.d/nut stop >> "$LOG_FILE" 2>&1
		;;
		hpux)
		/sbin/init.d/nut-drvctl stop >> "$LOG_FILE" 2>&1
		/sbin/init.d/nut-upsd stop >> "$LOG_FILE" 2>&1
		/sbin/init.d/nut-upsmon stop >> "$LOG_FILE" 2>&1
		;;
		aix)
		/etc/rc.d/init.d/ups stop >> "$LOG_FILE" 2>&1
		;;
		*)
		;;
	esac
}

add_hpux_upsmon_esd_support () {
	if [ -f /etc/rc.config.d/nut-upsmon ]; then
		cat >>/etc/rc.config.d/nut-upsmon <<HERE
##### IPP - Unix ESD support begin #####
# Do not remove nor change the line above, it's used
# for automatic removal of the section upon uninstallation
SHUTDOWN_TIMER=-1
if [ -f "/usr/local/ups/etc/ipp.conf" ]; then
	. /usr/local/ups/etc/ipp.conf
fi
if [ "\$SHUTDOWN_TIMER" -gt -1 ]; then
	# This host wants early shutdown support, must be root
	UPSMON_ARGS="\$UPSMON_ARGS -p"
fi
# Again, do not remove nor change the line below
##### IPP - Unix ESD support end #####
HERE
	fi
}

remove_hpux_upsmon_esd_support () {
	if /usr/bin/test -e /etc/rc.config.d/nut-upsmon; then
		awk '
		BEGIN {
			echo = 1;
		}

		/^##### IPP - Unix ESD support begin #####$/ {
			echo = 0;
		}

		/^##### IPP - Unix ESD support end #####$/ {
			echo = 1;
			next;
		}

		{
			if (echo) print $0;
		}
		' /etc/rc.config.d/nut-upsmon > /tmp/nut-upsmon.tmp.$$

		mv /tmp/nut-upsmon.tmp.$$ /etc/rc.config.d/nut-upsmon
	fi
}

add_profile_settings () {
	if [ -f /etc/profile ]; then
		cat >>/etc/profile <<HERE
##### IPP - Unix settings begin #####
# Do not remove nor change the line above, it's used
# for automatic removal of the section upon uninstallation
# NOTE: The xbin directory contains symlinks to a wrapper
# which sets the environment for packaged programs in bin;
# but the bin also has scripts.
PATH="\$PATH:/usr/local/ups/xbin:/usr/local/ups/bin"
export PATH
#LD_LIBRARY_PATH="/usr/local/ups/lib:\$LD_LIBRARY_PATH"
#export LD_LIBRARY_PATH
MANPATH="\$MANPATH:/usr/local/ups/share/man"
export MANPATH
# Again, do not remove nor change the line below
##### IPP - Unix settings end #####
HERE
	fi
}

remove_profile_settings () {
	if /usr/bin/test -e /etc/profile; then
		awk '
		BEGIN {
			echo = 1;
		}

		/^##### IPP - Unix settings begin #####$/ {
			echo = 0;
		}

		/^##### IPP - Unix settings end #####$/ {
			echo = 1;
			next;
		}

		{
			if (echo) print $0;
		}
		' /etc/profile > /tmp/profile.tmp.$$

		mv /tmp/profile.tmp.$$ /etc/profile
	fi
}

main () {
# Setup some globals
instpath=/usr/local/ups
#skip_install=true
#skip_license=true
#skip_service=true
#skip_config=true
ret=TRUE

# Must check parameters
	lang=""
	SYSTEM=""

	if [ "$1" != "" ] ; then
		get_parameters $1
	fi

	if [ "$2" != "" ] ; then
		get_parameters $2
	fi

	if [ "$3" != "" ] ; then
		get_parameters $3
	fi

# Get language locale
	if [ "$lang" = "" ]; then
		check_locale_language
		if [ -z "$lang" ]; then
			lang=EN
		fi
	fi

#  Initialize resource strings.
	installres="$COMMON_DIR"_$lang/install.res
	licenseres="$COMMON_DIR"_$lang/license.txt
	initDefines

	compute_SYSTEM

	systemdir="$system"
	NUTCONF="$systemdir/nutconf"

	who="`whoami 2>/dev/null`"
	if [ "$who" != 'root' ]; then
#work around in case no whoami is present
		who="`id -u 2>/dev/null`"
		if [ "$who" != '0' ]; then
			who="`id 2>/dev/null | grep -w '0' | grep -w root`"
			if [ -z "$who" ]; then
				necho $ERR_ROOT
				exit 1
			fi
		fi
	fi

# Say hello
#	we'll install vanilla IPP unix.
	clear
	echo
	echo
	echo "-----------------------------------------------------------------"
	echo

	echo "                      EATON"
	echo
#	echo "Welcome to IPP Unix!"
	necho $WELCOME_STR1

#	echo "         `pwd`/$0 Version 5.0.0"
	lineStr="`head "-$STR_VERSION" $installres |tail -1`"
	#echo "         `pwd`/$0 $lineStr $lineStr1"
	echo "                       $lineStr $IPP_VERSION"

	echo
#	echo "           To install IPP - Unix, select (y)"
#	echo "and fill in the configuration items as they are presented to you."
	necho $WELCOME_STR2
	necho $WELCOME_STR3
	echo
#	echo "The default install path name for this software is:  $instpath"
	lineStr="`head -$DEFAULT_PATH_STR $installres |tail -1`"
	echo "   $lineStr"
	echo "   $instpath"
	echo
	echo "-----------------------------------------------------------------"
	echo
#	echo "NOTE: If you already have LanSafe for Unix installed and you"
#	echo "      do not wish to re-install it, select (N)o to stop"
#	echo "      LanSafe for Unix installation."

	necho $INSTALL_INTRO_STR1
	necho $INSTALL_INTRO_STR2
	necho $INSTALL_INTRO_STR3
	echo
	echo

#	read_def "  Continue IPP - Unix installation? (y/n) [y] " "y"
	read_def $INSTALL_INTRO_STR4 "y"
	case "$answer" in
	[yY]|[yY][eE][sS])
		;;
	*)
		exit 0
		;;
	esac

	if [ x"$system" = x"Unknown System" ]
	then
		echo
#		echo "  Unable to determine your system."
		lineStr="`head -$ERR_UNKNOWN_SYS_STR1 $installres |tail -1`"
		echo "  $lineStr"
		exit 0
	fi	# end-of "if system = Unknown system"

	echo
	echo

# License Agreement
	if [ -z "$skip_license" ]; then
		echo " "
		more $licenseres
		echo " "
		necho $LICENSE_AGREEMENT_1
		echo
		necho $LICENSE_AGREEMENT_2
		necho $LICENSE_AGREEMENT_3
		necho $LICENSE_AGREEMENT_4
		echo

		read_def $LICENSE_AGREEMENT_5 "n"

		case "$answer" in
		[yY]|[yY][eE][sS])
			;;
		*)
			necho $ERR_LIC_AGREE
			exit 1
			;;
		esac
	fi

	stop_service

	# Install files
	if [ -z "$skip_install" ]; then
		install_files
		set_host_os_flavour
	fi

	echo
	echo

	# Build initial configuration
	if [ -z "$skip_config" ]; then
		PATH="$PATH:/usr/local/ups/xbin:/usr/local/ups/bin"
		export PATH
#		LD_LIBRARY_PATH="$instpath/lib:/usr/local/lib:$LD_LIBRARY_PATH"
#		export LD_LIBRARY_PATH
		initial_configure
	fi

	# Add IPP - Unix specific env. settings
	add_profile_settings

	# Start service
	if [ -z "$skip_service" ]; then
		start_service
	fi

# Say goodbye
	if [ "$conf_ok" = "ok" ]; then
		echo "---------------------------------------------------------------"
#		echo "     IPP - Unix was successfully installed on your system.     "
		lineStr="`head -$SUCCESS_INSTALL $installres |tail -1`"
		echo "     $lineStr"
		echo "---------------------------------------------------------------"
	else
		echo "-----------------------------------------------------------------------------"
#		echo "     WARNING: IPP - Unix was NOT successfully installed on your system.     "
		lineStr="`head -$UNSUCCESS_INSTALL $installres |tail -1`"
		echo "     $lineStr"
		echo "-----------------------------------------------------------------------------"
		echo
#		necho $INSTALL_ERROR
		exit 1
	fi
}

main $1 $2 $3