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 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236
|
#!/bin/sh
################### Start of $RCSfile: Install,v $ ##################
#
# $Source: /home/alb/afbackup/afbackup-3.3.8beta7/RCS/Install,v $
# $Id: Install,v 1.4 2004/07/08 20:34:42 alb Exp alb $
# $Date: 2004/07/08 20:34:42 $
# $Author: alb $
#
#
####### description ################################################
#
#
#
####################################################################
if [ _"$1" = _--testonly ] ; then
shift
adminprefix=/tmp
for f in services inetd.conf passwd group ; do
( test -f $adminprefix/$f || cp /etc/$f $adminprefix ; chmod u+w $adminprefix/$f ) >/dev/null 2>&1
done
fi
#### some basic settings
OSNAME=`uname -s|sed 's/[^a-zA-Z1-9]//g'`
umask 22
servicename="afbackup"
varstosave="servinstdir username userid groupid defdev servvarinstdir clntinstdir clntvarinstdir port use_des des_header des_include des_lib des_libdir disable_threads orduserrestore runclientconfig runserverconfig servicename activate_mserver mservicename mport add_mservice use_zlib zlib_include zlib_libdir usegcc chown_server_var libdesbug_enabled do_install optimizer_flags servnamalias"
#### read the cache file overriding defaults
if [ -r Install.cache ] ; then
grep '^[ ]*set[ ]' Install.cache >/dev/null
if [ $? -eq 0 ] ; then
# the old csh-syntax
CACHE=`sed 's/^[ ]*set[ ][ ]*//g' Install.cache | sed 's/=(/="/g;s/)$/"/g'`
else
CACHE=`cat Install.cache`
fi
eval "$CACHE"
fi
#### set defaults as not obtained from the cache file
if [ _"$servinstdir" = _ ] ; then
servinstdir="/usr/local/afbackup"
fi
if [ _"$clntinstdir" = _ ] ; then
clntinstdir="/usr/local/afbackup"
fi
if [ _"$port" = _ ] ; then
port=2988
fi
if [ _"$mport" = _ ] ; then
mport=`expr $port + 1`
fi
if [ _"$servnamalias" = _ ] ; then
servnamalias="Yes"
fi
if [ _"$orduserrestore" = _ ] ; then
orduserrestore="No"
fi
if [ _"$use_des" = _ ] ; then
use_des="No"
fi
if [ _"$des_header" = _ ] ; then
des_header="des.h"
fi
if [ _"$des_include" = _ ] ; then
des_include="../libdes"
fi
if [ _"$des_lib" = _ ] ; then
des_lib="-ldes"
fi
if [ _"$libdesbug_enabled" = _ ] ; then
libdesbug_enabled="No"
fi
if [ _"$use_zlib" = _ ] ; then
use_zlib="No"
fi
if [ _"$zlib_include" = _ ] ; then
zlib_include="/usr/local/include"
fi
if [ _"$zlib_libdir" = _ ] ; then
if [ _"$zlib_include" = _ ] ; then
zlib_libdir="/usr/local/lib"
fi
fi
if [ _"$servvarinstdir" = _ ] ; then
servvarinstdir="/var/logs/backup"
fi
if [ _"$clntvarinstdir" = _ ] ; then
clntvarinstdir="/var/logs/backup"
fi
if [ _"$activate_mserver" = _ ] ; then
activate_mserver="Yes"
fi
if [ _"$add_mservice" = _ ] ; then
add_mservice="Yes"
fi
if [ _"$mservicename" = _ ] ; then
mservicename="afmbackup"
fi
if [ _"$chown_server_var" = _ ] ; then
chown_server_var="Yes"
fi
if [ _"$disable_threads" = _ ] ; then
disable_threads="No"
fi
if [ _"$optimizer_flags" = _ ] ; then
optimizer_flags="-O2"
fi
if [ _"$do_install" = _ ] ; then
do_install="Yes"
fi
if [ _"$runclientconfig" = _ ] ; then
runclientconfig="Yes"
fi
if [ _"$runserverconfig" = _ ] ; then
runserverconfig="Yes"
fi
##########################################################################
#
# Utilities
#
##########################################################################
matches(){
echo "$1" | egrep -i "$2" >/dev/null
}
tolowercase(){
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
}
###########################################################################
yes_no(){
while true ; do
echo " "
echo_n 'Your choice (Yes/No) ['"$1"']: '
read yesno
if [ _"$yesno" = _ ] ; then
yesno="$1"
fi
if matches "$yesno" '^(ye?s?|no?)$' ; then
break
else
echo ' '
echo 'This is not a valid choice. Please try again.'
fi
done
if matches "$yesno" '^ye?s?$' ; then
yesno="yes"
else
yesno="no"
fi
test $yesno = yes
}
issymlink(){
return `/bin/ls -l1 "$1" |grep '^l' | wc -l`
}
save_cache_vars(){
echo_n "Saving cache, please wait ..."
/bin/rm -f Install.cache
touch Install.cache
for var in $varstosave ; do
set | grep '^'"$var"= >/dev/null
if [ $? -eq 0 ] ; then
eval valuestr='$'"$var"
echo "$var""='$valuestr'" >> Install.cache
fi
done
echo dummy | awk '{printf "\r \r"}'
}
#
# with exit status as argument
#
do_exit(){
save_cache_vars
exit $1
}
#
# which as sh function
#
find_program(){
for dir in `echo $PATH | tr : " "` ; do
if [ -x "$dir"/"$1" ] ; then
echo "$dir"/"$1"
return 0
fi
done
return 1
}
#
# get xinetd entry stanza
#
get_xinetd_entry(){
sed -n '/^\([ ]\)\?service[ ][ ]*'"$1"'\([ ].*\)\?/,/^[ ]*[}][ ]*/ p' "$2"
}
#
# get xinetd param value
#
get_xinetd_param(){
sed -n '/^\([ ]\)\?service[ ][ ]*'"$1"'\([ ].*\)\?/,/^[ ]*[}][ ]*/ p' "$3"|grep '^[ ]*'"$2"'[ ]*=[ ]*'|sed 's/^[^=]*=[ ]*//g'
}
#
# remove named xinetd entry from data stream
#
strip_xinetd_entry(){
sed '/^\([ ]\)\?service[ ][ ]*'"$1"'\([ ].*\)\?/,/^[ ]*[}][ ]*/ d' "$2"
}
#
# combine empty lines to one empty line
#
comb_empty_lines(){
awk 'BEGIN{s = 0;}{if(NF = 0){if(s = 0)print; s = 1}else{s = 0; print}}'
}
# return signal number by signal name
#
# seems csh is the only thing to print the signals without any scrolls
#
SIGNALLIST=`csh -f -c 'kill -l' | grep -v '^[ ]$' | awk '{ for(i = 1; i <= NF; i++) print $i }' | fgrep -vx NULL | sed 's/^SIG//g'`
signalbyname(){
echo "$SIGNALLIST" | egrep -n '^(SIG)?'"$1" | sed 's/:.*$//g'
}
####### add afbackup entry to /etc/services interactively
add_backup_service(){
servnamvar="$1"
eval servnam='"$'"$servnamvar"'"'
protnam="$2"
if [ _"$3" != _ ] ; then
portnumvar="$3"
eval portnum='"$'"$portnumvar"'"'
fi
echo ' '
echo 'An entry for the backup service is necessary in the system'
echo "file $adminprefix/services."
# add_service:
while true ; do
cont=no
servicesline=`egrep '^[ ]*('"$servnam"'|[^ ][^ ]*[ ][ ]*[^ ].*[ ]'"$servnam"')([ ].*)?$' $adminprefix/services`
serviceslinen=`echo $servicesline | wc -w`
if [ $serviceslinen -gt 0 ] ; then
while true ; do
echo "There exists an entry for this service in $adminprefix/services."
echo "It looks like this:"
echo ' '
echo "$servicesline"
echo ' '
echo 'Should we remove this entry and create a new one, or add another ?'
echo '(If no is chosen, the existing entry will be used)'
echo ' '
echo_n 'Your choice (Yes/No/Add) [No]: '
read c
echo ' '
if [ _"$c" = _ ] ; then
c="no"
fi
if matches "$c" '^(ye?s?|no?|ad?d?)$' ; then
break
else
echo "Invalid choice. Please try again."
echo ' '
fi
done
if matches "$c" '^ad?d?' ; then
# newservname:
while true ; do
echo " "
echo_n "Enter a name for the new service: "
read c
if matches "$c" '^[a-zA-Z0-9_-]*$' ; then
break
fi
echo " "
echo "A service name should contain only A-Z, a-z, 0-9, _ or -"
echo "Please try again."
done
servnam="$c"
continue
fi
if matches "$c" '^ye?s?$' ; then
panic=0
cp -p $adminprefix/services $adminprefix/services.$$
CPST=$?
saved_files="$saved_files $adminprefix/services.$$"
if [ ! -f $adminprefix/services.$$ -o $CPST -ne 0 ] ; then
echo "Panic: cannot make backup copy of $adminprefix/services."
echo "I'll not go on to add the entry. You have to do it yourself."
panic=1
else
NEWSRVF=`egrep -v '^[ ]*('"$servnam"'|[^ ][^ ]*[ ][ ]*[^ ].*[ ]'"$servnam"')([ ].*)?$' "$adminprefix"/services`
cp -p "$adminprefix"/services "$adminprefix"/services.tmp.$$ \
&& echo "$NEWSRVF" > "$adminprefix"/services.tmp.$$ \
&& /bin/mv "$adminprefix"/services.tmp.$$ "$adminprefix"/services
if [ $? -ne 0 ] ; then
echo "Error: removing entry from the system file failed."
panic=1
fi
fi
if [ $panic -ne 0 ] ; then
echo "The following line must be removed from $adminprefix/services"
echo ' '
egrep '^[ ]*('"$servnam"'|[^ ][^ ]*[ ][ ]*[^ ].*[ ]'"$servnam"')([ ].*)?$' "$adminprefix"/services
echo " "
echo "Please hit enter when you are done with it."
read a
fi
continue
fi
if [ `matches "$c" '^no?$'` ] ; then
portnum=`echo "$servicesline"|awk '{print $2}'|cut -d/ -f1|awk '{print $1}'`
fi
else
while [ `grep -i "$portnum"/"$protnam" "$adminprefix"/services|grep -v $servnam|wc -l` -gt 0 ] ; do
portnum=`expr $portnum + 1`
done
# portserviceselection:
while true ; do
if [ $portnum = 2988 ] ; then
hint=' (hex 0xbac)'
else
hint=''
fi
echo ' '
echo "Should we add an entry to $adminprefix/services for this"
echo 'service ? Default port number is '"$portnum$hint"'. If'
echo 'you do not want to add an entry, just enter no. If you'
echo 'would like to use a different port number, enter it. If'
echo 'you want a service name different from '"$servnam"','
echo 'enter it (all lowercase letters, numbers or -, please).'
echo 'If everything is ok, enter yes.'
while true ; do
echo " "
echo_n 'Your choice (Yes/No/port/servicename) [Yes]: '
read c
if [ _"$c" = _ ] ; then
c='Yes'
fi
if matches "$c" '^(ye?s?|no?|[0-9][0-9]*|[a-z][a-z0-9-]*)$' ; then
break
fi
echo ' '
echo 'This is not a valid choice. Please try again.'
done
if matches "$c" '^[0-9][0-9]*$' ; then
portnum="$c"
echo " "
echo "Ok, port number changed to $c."
if [ `grep -c '^[ ]*[a-z][a-z0-9-]*[ ][ ]*'"$c/"'[tT][Cc][Pp]' $adminprefix/services` -gt 0 ] ; then
echo "Warning: Port number $c is already used in $adminprefix/services."
fi
continue
fi
matches "$c" '^(ye?s?|no?)$'
M=$?
if test $M -ne 0 && matches "$c" '^[a-z][a-z0-9-]*$' ; then
servnam="$c"
echo " "
echo "Ok, service name changed to $c."
if [ `egrep '^[ ]*('"$c"'[ ][ ]*[1-9][0-9]*/[tT][Cc][Pp]|[^ ][^ ]*[ ][ ]*[1-9][0-9]*/[tT][Cc][Pp].*[ ]'"$c"')([ ].*)?$' $adminprefix/services|wc -l` -gt 0 ] ; then
echo "Hm, service name $c is already used in $adminprefix/services."
cont=yes
break
fi
continue
fi
if matches "$c" '^no?$' ; then
:
else
servicesline=`egrep '^[ ]*[a-z][a-z0-9-]*[ ][ ]*'"$portnum/"'[tT][Cc][Pp]([ ].*)?$' $adminprefix/services | egrep -v '^(.*[ ])?'"$servnam"'([ ].*)?$'`
lineadded="no"
if [ `echo $servicesline | wc -w` -gt 0 ] ; then
echo ' '
echo "Warning: The port number $portnum is already used in $adminprefix/services,"
echo "but without an entry for the name $servnam. It looks like this:"
echo ' '
echo "$servicesline"
echo ' '
echo "Should the existing entry be extended with $servnam as an alias name ?"
if yes_no $servnamalias ; then
servnamalias=Yes
cp -p $adminprefix/services $adminprefix/services.$$
CPST=$?
saved_files="$saved_files $adminprefix/services.$$"
if [ ! -f $adminprefix/services.$$ -o $CPST -ne 0 ] ; then
echo "Panic: cannot make backup copy of $adminprefix/services."
echo "I'll not go on to add the entry. Please do it yourself"
echo "and press Return, when done."
read v
else
servlineentry=`egrep '^[ ]*[a-z][a-z0-9-]*[ ][ ]*'"$portnum/"'[tT][Cc][Pp]([ ].*)?$' $adminprefix/services | egrep -v '^(.*[ ])?'"$servnam"'([ ].*)?$'`
servlineno=`egrep -n '^[ ]*[a-z][a-z0-9-]*[ ][ ]*'"$portnum/"'[tT][Cc][Pp]([ ].*)?$' "$adminprefix"/services | sed 's/:.*$//g'`
comment=`echo "$servlineentry"|grep '#'|sed 's/^[^#]*#/ #/g'`
thebeef=`echo "$servlineentry"|sed 's/[ ]*#.*//g'`
cp -p "$adminprefix"/services $adminprefix/services.$$.2
awk '{if(NR == '"$servlineno"') printf "%s '"$servnam"'%s\n","'"$thebeef"'","'"$comment"'"; else print $0}' $adminprefix/services.$$ > $adminprefix/services.$$.2
NDIFF1=`diff $adminprefix/services.$$ $adminprefix/services.$$.2 | grep '^< ' | wc -l`
NDIFF2=`diff $adminprefix/services.$$ $adminprefix/services.$$.2 | grep '^> ' | wc -l`
if [ $NDIFF1 = 1 -a $NDIFF2 = 1 ] ; then
/bin/mv $adminprefix/services.$$.2 $adminprefix/services
else
/bin/rm -f $adminprefix/services.$$.2
echo "Error: Could not modify $adminprefix/services correctly."
echo "Please do it manually and press Return afterwards."
read v
fi
fi
lineadded="yes"
else
continue
fi
fi
if [ $lineadded = no ] ; then
echo "$servnam $portnum/$protnam" >> $adminprefix/services
fi
fi
break
done
fi
if [ _"$cont" != _yes ] ; then
break
fi
done
eval "$servnamvar"='"'"$servnam"'"'
eval "$portnumvar"='"'"$portnum"'"'
}
################### add entry to /etc/inetd.conf file
add_inetd_entry(){
servnam="$1"
waitforexit="$2"
prognam="$3"
protnam=tcp
waityesno="no"
if [ $waitforexit = "wait" ] ; then
waityesno="yes"
fi
echo 'An entry for this service is necessary in the system'
echo "file $inetdfile."
while true ; do
# add_inetdentry:
if [ $use_xinetd -ne 0 ] ; then
inetdentry=`get_xinetd_entry $servnam $inetdfile`
else
inetdentry=`egrep '^[ ]*'"$servnam"'([ ].*)?$' $inetdfile`
fi
inetdentryn=`echo $inetdentry|wc -w`
if [ $inetdentryn -gt 0 ] ; then
echo "There exists an entry in $inetdfile."
echo "It looks like this:"
echo ' '
if [ $use_xinetd -ne 0 ] ; then
get_xinetd_entry $servnam $inetdfile
else
echo "$inetdentry"
fi
echo ' '
def="No"
if [ $use_xinetd -eq 0 ] ; then
I=1
N=`echo "$inetdentry" | wc -w`
while [ $I -le $N ] ; do
eval i"$I"='"'`echo "$inetdentry" | awk '{print $'"$I"'}'`'"'
I=`expr $I + 1`
done
if matches "$i6""/" ^"$servinstdir""/" ; then
:
else
echo 'The directory path in this entry seems to be wrong (It'
echo 'should be '"$servinstdir"'/... )'
def="Yes"
fi
if matches "$i6" /"$prognam"'$' && matches "$i7" /"$prognam"'$' ; then
:
else
echo "The program name in this entry is wrong (it must be $prognam)."
def="Yes"
fi
if matches "$i7""/" '^'"$servinstdir""/" ; then
:
else
echo 'The program path in this entry is wrong ('"it must be $servinstdir/$prognam"').'
def="Yes"
fi
if [ _"$i5" != _"$username" ] ; then
echo 'The username in this entry is wrong (should be '$username').'
def="Yes"
fi
i3=`echo "$i3" | tolowercase`
if [ "$i3" != "$protnam" -o "$i4" != "$waitforexit" -o "$i2" != stream ] ; then
echo 'The protocol in this entry is wrong (we are allowing'
if [ "$waitforexit" = "nowait" ] ; then
echo 'several server processes).'
else
echo 'only one server process)'
fi
def="Yes"
fi
else
# xinetd
server=`get_xinetd_param "$servnam" server "$inetdfile"`
if matches "$server""/" '^'"$servinstdir""/" ; then
:
else
echo 'The directory path in this entry seems to be wrong (It'
echo 'should be '"$servinstdir"'/... )'
def="Yes"
fi
server_args=`get_xinetd_param "$servnam" server_args "$inetdfile"`
I=1
N=`echo "$server_args" | wc -w`
while [ $I -le $N ] ; do
eval server_args"$I"='"'`echo "$server_args" | awk '{print $'"$I"'}'`'"'
I=`expr $I + 1`
done
if matches "$server" /"$prognam"'$' && matches "$server_args1" /"$prognam"'$' ; then
:
else
echo "The program name in this entry is wrong (it must be $prognam)."
def="Yes"
fi
if matches "$server_args1""/" ^"$servinstdir""/" ; then
:
else
echo 'The program path in this entry is wrong (it must be '$servinstdir'/$prognam).'
def="Yes"
fi
user=`get_xinetd_param $servnam user $inetdfile`
if [ "$user" != "$username" ] ; then
echo 'The username in this entry is wrong (should be '"$username"').'
def="Yes"
fi
prot=`get_xinetd_param "$servnam" protocol "$inetdfile" | tolowercase`
wait=`get_xinetd_param "$servnam" wait "$inetdfile"`
sockt=`get_xinetd_param "$servnam" socket_type "$inetdfile"`
if [ "$prot" != "$protnam" -o "$wait" != "$waityesno" -o "$sockt" != "stream" ] ; then
echo 'The protocol in this entry is wrong (we are allowing'
if [ "$waitforexit" = "nowait" ] ; then
echo 'several server processes).'
else
echo 'only one server process)'
fi
def="Yes"
fi
flags=`get_xinetd_param "$servnam" flags "$inetdfile"`
echo "$flags" | egrep '^(.* )?REUSE( .*$)?' >/dev/null
reuse="$?"
echo "$flags" | egrep '^(.* )?NAMEINARGS( .*$)?' >/dev/null
nameinargs="$?"
if [ $nameinargs -ne 0 -o $reuse -ne 0 ] ; then
echo 'The flags in this entry are wrong (REUSE and NAMEINARGS must be set)'
def="Yes"
fi
fi
if [ $def != "No" ] ; then
echo " "
fi
echo 'Should we remove this entry and create a new one ?'
if yes_no "$def" ; then
panic=0
cp -p "$inetdfile" "$inetdfile.$$"
saved_files="$saved_files $inetdfile.$$"
if [ ! -f "$inetdfile.$$" ] ; then
echo "Panic: cannot make backup copy of $inetdfile."
echo "I'll not go on to add the entry. You have to do it yourself."
panic=1
else
if [ $use_xinetd -ne 0 ] ; then
NEWINETDF=`strip_xinetd_entry "$servnam" "$inetdfile" | comb_empty_lines`
else
NEWINETDF=`egrep -v '^[ ]*'"$servnam"'([ ].*)?$' "$inetdfile"`
fi
echo "$NEWINETDF" > "$inetdfile".tmp.$$ \
&& /bin/mv "$inetdfile".tmp.$$ "$inetdfile"
if [ $? -ne 0 ] ; then
echo "Error: removing entry from the system file failed."
panic=1
fi
fi
if [ $panic -ne 0 ] ; then
echo "The following line must be removed from $inetdfile"
echo ' '
echo "$inetdline"
echo " "
echo "Please hit enter when you are done with it."
read a
fi
continue
else
if [ $use_xinetd -ne 0 ] ; then
user=`get_xinetd_param "$servnam" user "$inetdfile"`
else
line=`egrep '^[ ]*'"$servnam"'([ ].*)?$' "$inetdfile"`
I=1
N=`echo "$line" | wc -w`
while [ $I -le $N ] ; do
eval line$I'="'`echo "$line" | awk '{print $'"$I"'}'`'"'
I=`expr $I + 1`
done
username="$line5"
fi
fi
else
echo ' '
echo "Should we add an entry to $inetdfile for this"
echo 'service ? Default username is '$username'. If you do not'
echo 'want to add an entry, just enter no. If you would like'
echo 'to run the server under a different username, enter it.'
echo 'If everything is ok, enter yes.'
# askaddinetd:
echo ' '
echo_n "Your choice (Yes/No/username) [Yes]: "
c=""
read c
if [ _"$c" = _ ] ; then
c="Yes"
fi
if matches "$c" '^(ye?s?|no?)$' ; then
:
else
username="$c"
fi
if matches "$c" '^no?$' ; then
:
else
if [ $use_xinetd -ne 0 ] ; then
cut -c14- >> $inetdfile << EOF
>
> service $servnam
> {
> flags = REUSE NAMEINARGS
> socket_type = stream
> protocol = $protnam
> wait = $waityesno
> user = $username
> server = $servinstdir/server/bin/$prognam
> server_args = $servinstdir/server/bin/$prognam $servinstdir/server/etc/backup.conf
> }
EOF
else
echo "$servnam stream $protnam $waitforexit $username $servinstdir/server/bin/$prognam $servinstdir/server/bin/$prognam $servinstdir/server/etc/backup.conf" >> $inetdfile
fi
fi
fi
break
done
}
####### add user and group entry to /etc/passwd and /etc/group
add_user_group(){
myusername="$1"
userid="$2"
groupid="$3"
passwdfile="$adminprefix/passwd"
if [ `matches "$OSNAME" OpenBSD` ] ; then
passwdfile="$adminprefix/master.passwd"
fi
if [ `grep -c '[ ]*'"$myusername": $passwdfile` -lt 1 ] ; then
echo "No user entry found for $myusername in $passwdfile."
echo ' '
echo_n 'Should we add an entry ? '
if yes_no Yes ; then
if [ _"$userid" = _ ] ; then
userid=2988
fi
while [ `cut -f3 -d: $passwdfile|grep -c "^$userid"'$'` -gt 0 ] ; do
userid=`expr $userid + 1`
done
echo " "
echo "The default user-ID is $userid. If this is ok, just"
echo "enter yes. If not, enter the desired ID."
# askforuserid:
while true ; do
echo " "
echo_n 'Your choice (Yes/No/userid) [Yes]: '
read c
if [ _"$c" = _ ] ; then
c='Yes'
fi
if matches "$c" '^(ye?s?|no?|[0-9][0-9]*)$' ; then
if matches "$c" '^[0-9][0-9]*$' ; then
userid="$c"
elif matches "$c" '^n' ; then
echo "Please enter the desired user-ID."
continue
fi
break
fi
echo ' '
echo 'This is not a valid choice. Please try again.'
done
if [ `cut -f3 -d: $passwdfile|grep -c "^$userid"'$'` -gt 0 ] ; then
echo "Warning: A user entry with the user-ID $userid already exists"
echo " on the system. Using it nonetheless."
fi
if [ _"$groupid" = _ ] ; then
groupid=14
fi
while [ `cut -f3 -d: $adminprefix/group|grep -c "^$groupid"'$'` -lt 1 ] ; do
groupid=`expr $groupid - 1`
if [ $groupid -eq 0 ] ; then
break
fi
done
while [ `cut -f3 -d: $adminprefix/group|grep -c "^$groupid"'$'` -lt 1 ] ; do
groupid=`expr $groupid + 1`
done
echo " "
echo "The default group-ID is $groupid. If this is ok, just"
echo "enter yes. If not, enter the desired ID."
# askforgroupid:
while true ; do
echo " "
echo_n 'Your choice (Yes/No/groupid) [Yes]: '
read c
if [ _"$c" = _ ] ; then
c='Yes'
fi
if matches "$c" '^(ye?s?|no?|[0-9][0-9]*)$' ; then
if matches "$c" '^[0-9][0-9]*$' ; then
groupid="$c"
if [ `cut -f3 -d: "$adminprefix"/group|grep -c "^$groupid"'$'` -lt 1 ] ; then
echo "Warning: A group entry with this group-ID does not exist"
echo " in the system. Using it nonetheless."
fi
elif matches "$c" '^n' ; then
echo "Please enter the desired group-ID."
continue
fi
break
fi
echo ' '
echo 'This is not a valid choice. Please try again.'
done
panic=0
/bin/cp -p $passwdfile $passwdfile.$$
saved_files="$saved_files $passwdfile.$$"
tmppasswdfile="$passwdfile.tmp.$$"
if [ ! -f $passwdfile.$$ ] ; then
echo "Panic: cannot make backup copy of $passwdfile."
echo "I'll not go on to add the user. You have to do it yourself."
panic=1
else
if [ `grep -c '^+' $passwdfile` -gt 0 ] ; then
/bin/rm -f $tmpfile
echo "/^+/ i\\" > $tmpfile
echo "$myusername":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:" \
>>$tmpfile
NEWPASSWDF=`sed -f $tmpfile $passwdfile`
if [ $? -ne 0 ] ; then
echo "Error: adding the user to the system file failed."
panic=1
else
if matches "$OSNAME" OpenBSD ; then
echo "$NEWPASSWDF" > $tmppasswdfile \
&& pwd_mkdb $tmppasswdfile \
&& echo "$NEWPASSWDF" > $tmppasswdfile \
&& pwd_mkdb -p $tmppasswdfile \
&& /bin/rm -f $tmppasswdfile # just in case pwd_mkdb forgets it
EST=$?
else
echo "$NEWPASSWDF" > $passwdfile
EST=$?
fi
if [ $EST -ne 0 ] ; then
echo "Error: adding the user to the system file failed."
panic=1
fi
fi
else
if matches "$OSNAME" OpenBSD ; then
/bin/rm -f $tmpfile \
&& /bin/cp -p $passwdfile $tmpfile \
&& echo "$myusername":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:" \
>> $tmpfile \
&& /bin/cp -p $tmpfile $tmppasswdfile \
&& pwd_mkdb $tmppasswdfile \
&& /bin/cp -p $tmpfile $tmppasswdfile \
&& pwd_mkdb -p $tmppasswdfile # just in case pwd_mkdb forgets it
EST=$?
else
echo "$myusername":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:" \
>> $passwdfile
EST=$?
fi
if [ $EST -ne 0 ] ; then
echo "Error: adding the user to the system file failed."
panic=1
fi
fi
fi
fi
if [ $panic -ne 0 ] ; then
echo "The following line must be added to $passwdfile"
echo '(before the line starting with a +, if present):'
echo ' '
echo "$myusername":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:"
echo " "
echo "Please hit enter when you are done with it."
read a
fi
fi
username="$myusername"
}
################################################################################
intrexit(){
echo ' '
save_cache_vars
exit `expr 128 + $1`
}
#############################################################################
#
# resolve all symlinks in path, the only argument
#
resolvepath(){
oldpath="$1"
newpath="$oldpath"_
while [ _"$newpath" != _"$oldpath" ] ; do
newpath="$oldpath"
oldpath=`echo "$oldpath"|sed 's#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`
if [ "$oldpath" != '/' ] ; then
oldpath=`echo "$oldpath"|sed 's#/*$##g'`
fi
done
if [ _`echo "$oldpath"|cut -c1` = _"/" ] ; then
oldhead="/"`echo "$oldpath"|cut -c2-|sed 's#/.*$##g'`
oldtail=`echo "$oldpath"|cut -c2-|sed 's#^[^/]*/##'`
else
oldhead=`echo "$oldpath"|sed 's#/.*$##g'`
oldtail=`echo "$oldpath"|sed 's#^[^/]*/##'`
fi
if [ _"$oldpath" = _"$oldhead" ] ; then
oldtail=""
fi
while true ; do
if [ _"$oldhead" = _ ] ; then
oldhead="."
fi
if [ ! -f "$oldhead" -a ! -d "$oldhead" ] ; then
echo ""
return 0
fi
linkchar=`ls -ld "$oldhead"|cut -c1`
if [ $linkchar = 'l' ] ; then
points_to=`ls -ld "$oldhead"|sed 's#^.*->[ ]*##g'`
if [ `echo "$points_to"|cut -c1` = '/' ] ; then
newpath="$points_to"/"$oldtail"
else
newpath=`dirname "$oldhead"`/"$points_to"/"$oldtail"
fi
echo `resolvepath "$newpath"`
return $?
fi
if [ _"$oldtail" = _ ] ; then
oldpath="$oldhead"
break
fi
oldhead="$oldhead"/`echo "$oldtail"|sed 's#/.*$##g'`
if [ `echo "$oldtail"|grep /|wc -l` -lt 1 ] ; then
oldtail=''
else
oldtail=`echo "$oldtail"|sed 's#^[^/]*/##g'`
fi
done
newpath="$oldpath"_
while [ _"$newpath" != _"$oldpath" ] ; do
newpath="$oldpath"
oldpath=`echo $oldpath|sed 's#[^/][^/]*/\.\./##g;s#[^/][^/]*/\.\.$##g;s#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`
if [ "$oldpath" != '/' ] ; then
oldpath=`echo "$oldpath"|sed 's#/*$##g'`
fi
done
echo "$newpath"
return 0
}
#########################
# returns 1 if GNU make, 0 if vendor non-GNU make
#
which_make(){
gmake=`find_program gmake`
if [ `echo $gmake | wc -w` -gt 0 ] ; then
if matches "$gmake" "^/" ; then
echo $gmake
return 1
fi
fi
make=`find_program make`
if [ `echo $make | wc -w` -gt 0 ] ; then
$make -v -n >/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo $make
return 0
fi
fi
# GNU make in disguise
if [ `make -v -n 2>&1 | grep GNU | wc -l` -gt 0 ] ; then
echo make
return 1
fi
echo gmake
return 1
}
### SERVER ONLY ###
server_only(){
echo " "
echo "Ok, we're going to install only the server side on this"
echo_n "machine. "
server_install
}
### CLIENT ONLY ###
client_only(){
echo " "
echo "Ok, we're going to install only the client side on this"
echo_n "machine. "
client_install
}
### REMOTELY STARTED CLIENT ###
remclient(){
echo " "
echo "Ok, we're going to install the client with remote start"
echo_n "option. "
server_install
}
### CLIENT, SERVER AND REMOTE START OPTION ###
all(){
echo " "
echo "Ok, we will install the client, server and remote start"
echo_n "option. "
server_install
}
################## CLIENT INSTALLATION ##################
client_install(){
while true ; do
# ask_for_clntinstdir:
echo "First you have to choose where we should install"
echo "the files and programs. Please enter a directory"
echo 'of your choice (you may supply the same directory'
echo 'as for the server side).'
echo 'Enter yes if '"$clntinstdir"' is ok.'
echo 'Otherwise please enter an alternate directory.'
# choose_clntinstdir:
while true ; do
echo ' '
echo_n 'Your choice (Yes/No/path) [Yes]: '
read choice
if [ _"$choice" = _ ] ; then
choice="yes"
fi
if matches "$choice" 'no?' ; then
echo_n "Please enter the directory: "
read choice
if matches "$choice" '^/' ; then
clntinstdir="$choice"
break
fi
fi
if matches "$choice" '^/' ; then
clntinstdir="$choice"
fi
if matches "$choice" '^(ye?s?|no?|/.*)$' ; then
break
fi
echo " "
echo "That's no valid choice. Please Try again."
done
choose_DES
echo " "
choose_ZLIB
echo " "
choose_optimization
echo " "
echo "Do you want ordinary users to be able to restore their"
echo "own files and/or directories without administrator help ?"
# orduserclnt:
yes_no $orduserrestore
orduserrestore=$yesno
echo " "
echo "Now we have to build the programs. Please stand by"
echo "and watch for error messages. If any occur you have"
echo "a problem. Warnings can usually be ignored. If errors"
echo "occur, drop a mail to the author"
echo '(af@muc.de)'
echo 'with the fault message(s) of make or try to patch the'
echo "stuff yourself. If you succeed, please also drop a"
echo "mail to the author, so your changes can be added to the"
echo "distribution."
echo " "
echo "Running configure now ..."
echo " "
$CONF_INTERPR ./configure -prefix="$clntinstdir" --without-prefixext \
--with-rexecdir="$clntinstdir"/server/rexec \
$configure_options
s="$?"
echo " "
if [ $s -ne 0 ] ; then
echo "Damn. Something went wrong. Please contact the author."
echo "Stopping here."
do_exit 1
fi
if matches "$libdesbug_enabled" '^yes$' ; then
if [ `grep -c LIBDESBUG_COMPATIBILITY des_aux.h` -lt 1 ] ; then
echo '#define LIBDESBUG_COMPATIBILITY 1' >> des_aux.h
fi
fi
echo "Running make now ..."
echo " "
$MAKECMD client $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
echo " "
if [ $s -ne 0 ] ; then
echo "Damn. Something went wrong. Please contact the author."
echo "Stopping here."
do_exit 1
fi
ask_install
echo " "
echo "We're now going to install the files and programs."
echo " "
$MAKECMD install.client $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
if [ $s = 0 && `matches "$orduserrestore" 'ye?s?'` ] ; then
$MAKECMD install.userrestore $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
# /bin/rm -f $clntinstdir/client/bin/afrestore \
# $clntinstdir/client/bin/afbackout \
# $clntinstdir/client/bin/backout \
# $clntinstdir/client/bin/restore
# cp $clntinstdir/client/bin/full_backup \
# $clntinstdir/client/bin/afrestore
# ln $clntinstdir/client/bin/afrestore $clntinstdir/client/bin/afbackout
# ln -s afbackout $clntinstdir/client/bin/backout
# ln -s afrestore $clntinstdir/client/bin/restore
# chmod 4755 $clntinstdir/client/bin/afrestore
# chmod 755 $clntinstdir/client/bin/xafrestore $clntinstdir/client/bin/__packpats
fi
echo " "
if [ $s -ne 0 ] ; then
echo "Oops, something went wrong. Maybe your directory choice is"
echo "somewhat problematic. Choose one of: Abort, Retry (A/R)"
mult_choice R '[AaRr]'
if [ _"$the_choice" = _ ] ; then
the_choice="r"
fi
if matches "$the_choice" '^a' ; then
do_exit 1
else
continue
fi
fi
break
done
add_backup_service servicename tcp port
echo ' '
echo 'Do you want to add an entry to '"$adminprefix/services"
echo 'for the multi stream server ?'
yes_no "$add_mservice"
add_mservice=$yesno
if [ "$add_mservice" = "yes" ] ; then
add_backup_service mservicename tcp mport
fi
echo " "
echo "You might now want to move the variable part of the"
echo "client side installation to the /var-directory. The"
echo "default directory is $clntvarinstdir. If you want to"
echo "do this and this directory is ok, just enter yes. If"
echo 'the directory is not ok, enter the desired one (you'
echo 'may supply the same as for the server side). If you'
echo "want to skip this step, just enter no."
# mvclntvar:
while true ; do
echo ' '
echo_n 'Your choice (Yes/No/path) [No]: '
read c
if [ "$c" = "" ] ; then
c="no"
fi
if matches "$c" '^(ye?s?|no?|/.*)$' ; then
break
fi
echo ' '
echo "Invalid choice. Please try again."
done
if matches "$c" '^/' ; then
clntvarinstdir="$c"
fi
if matches "$c" '^no?$' ; then
:
else
mkdir -p "$clntvarinstdir"
curwd=`pwd`
cd "$clntinstdir"/client
if issymlink var ; then
echo " "
echo "Warning: The directory seems to have been moved already."
echo " Please check where $clntinstdir/client/var"
echo " points to. Not moving anything."
else
tar cf - var | (cd "$clntvarinstdir"; tar xf -)
mv "$clntvarinstdir"/var "$clntvarinstdir"/client
/bin/rm -rf var
ln -s "$clntvarinstdir"/client var
fi
fi
echo ' '
echo "Now we may run the program $clntinstdir/client/bin/clientconfig"
echo "so you can configure the client side of the backup system. Would"
echo 'you like to do this now ?'
yes_no "$runclientconfig"
runclientconfig="$yesno"
if matches "$runclientconfig" 'ye?s?' ; then
"$clntinstdir"/client/bin/clientconfig
fi
}
################ SERVER INSTALLATION #################
server_install(){
while true ; do
echo "First you have to specify where to install the"
echo "files and programs. Please enter a directory of"
echo 'your choice (you may supply the same directory'
echo 'as for the client side).'
echo "If '$servinstdir' is fine enter yes."
echo 'Otherwise enter an alternate directory, please.'
while true ; do
echo ' '
echo_n 'Your choice (Yes/No/path) [Yes]: '
read choice
if [ _"$choice" = _ ] ; then
choice="yes"
fi
if matches "$choice" 'no?' ; then
echo_n "Please enter the directory: "
read choice
if matches "$choice" '^/' ; then
serverinstdir="$choice"
break
fi
fi
if matches "$choice" '^/' ; then
servinstdir="$choice"
fi
if matches "$choice" '^(ye?s?|no?|/.*)$' ; then
break
fi
echo " "
echo "That's no valid choice. Please Try again."
done
clntinstdir="$servinstdir"
choose_DES
echo " "
choose_ZLIB
echo " "
if [ $mode != "clntrem" -a $mode != "servonly" ] ; then
echo " "
echo "Do you want ordinary users to be able to restore their"
echo "own files and/or directories without administrator help ?"
yes_no $orduserrestore
orduserrestore=$yesno
fi
choose_threads
choose_optimization
echo " "
echo "Now we have to build the programs. Please stand by"
echo "and watch for error messages. If any occur you have"
echo "a problem. Warnings can usually be ignored. If errors"
echo 'occur, drop a mail to the author (af@muc.de)'
echo 'with the fault message(s) of make or try to patch the'
echo "stuff yourself. If you succeed, please also drop a"
echo "mail to the author, so your changes can be added to the"
echo "distribution."
echo " "
echo "Running configure now ..."
echo " "
$CONF_INTERPR ./configure -prefix="$servinstdir" --without-prefixext \
--with-rexecdir="$servinstdir"/server/rexec \
$configure_options
s="$?"
echo " "
if [ $s -ne 0 ] ; then
echo "Damn. Something went wrong. Please contact the author."
echo "Stopping here."
do_exit 1
fi
if matches "$libdesbug_enabled" '^yes$' ; then
if [ `grep -c LIBDESBUG_COMPATIBILITY des_aux.h` -lt 1 ] ; then
echo '#define LIBDESBUG_COMPATIBILITY 1' >> des_aux.h
fi
fi
echo "Running make now ..."
echo " "
if [ $mode = "all" -o $mode = "clntrem" ] ; then
$MAKECMD $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
else
$MAKECMD server $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
fi
echo " "
if [ $s -ne 0 ] ; then
echo "Damn. Something went wrong. Please contact the author."
echo "Stopping here."
do_exit 1
fi
ask_install
echo " "
echo "We're now going to install the files and programs."
echo " "
if [ $mode = "all" -o $mode = "clntrem" ] ; then
$MAKECMD install install.rclient $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
else
$MAKECMD install.server $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
fi
if test $s -eq 0 && matches "$orduserrestore" 'ye?s?' ; then
$MAKECMD install.userrestore $MAKEOPTS OPTIMIZE="$optimizer_flags"
s="$?"
# /bin/rm -f $servinstdir/client/bin/afrestore \
# $servinstdir/client/bin/afbackout \
# $servinstdir/client/bin/backout \
# $servinstdir/client/bin/restore
# cp $servinstdir/client/bin/full_backup \
# $servinstdir/client/bin/afrestore
# ln $servinstdir/client/bin/afrestore $servinstdir/client/bin/afbackout
# ln -s afbackout $servinstdir/client/bin/backout
# ln -s afrestore $servinstdir/client/bin/restore
# chmod 4755 $servinstdir/client/bin/afrestore
# chmod 755 $servinstdir/client/bin/xafrestore $servinstdir/client/bin/__packpats
fi
echo " "
if [ $s -ne 0 ] ; then
echo "Oops, something went wrong. Maybe your directory choice is"
echo "somewhat problematic. Choose one of: Abort, Retry (A/R)"
mult_choice R '[AaRr]'
if [ _"$the_choice" = _ ] ; then
the_choice="r"
fi
if matches "$the_choice" '^a' ; then
do_exit 1
else
continue
fi
fi
break
done
/bin/rm -f $tmpfile
add_backup_service servicename tcp port
if [ _"$username" = _ ] ; then
if [ $mode = "all" -o $mode = "clntrem" ] ; then
username="root"
else
username="backup"
fi
fi
echo ' '
add_inetd_entry "$servicename" nowait afserver
echo ' '
echo 'Do you want to activate the multi stream server ?'
yes_no "$activate_mserver"
activate_mserver="$yesno"
if [ "$activate_mserver" = "yes" ] ; then
echo ' '
echo 'The multi-stream server should use a different port than the'
echo 'normal server, so we now configure the appropriate entries'
echo 'for the system files.'
add_backup_service mservicename tcp mport
echo ' '
add_inetd_entry "$mservicename" wait afmserver
fi
echo ' '
add_user_group "$username" "$userid" "$groupid"
RESTRSERVERFILES="afmserver afserver label_tape cartready"
for SF in $RESTRSERVERFILES ; do
chown "$username" "$servinstdir"/server/bin/$SF
done
if [ "$username" != "root" ] ; then
echo ' '
echo "The user ID the server will run under is not root."
echo "So we are now going do change the ownership of the"
echo "directory containing varying serverside files and"
echo "storing persistent information for the server to the"
echo "user $username. Furthermore all the files residing in"
echo "this directory will change the owner the same way. If"
echo "we wouldn't do so, the server would not be able to modify"
echo "these files. That could result in really bad situations."
echo "If you consider this as dangerous or disadvantageous, or "
echo "if there's any reason to not like it then enter no now."
echo ' '
echo "Change owner of $servinstdir/server/var/* to $username ?"
yes_no "$chown_server_var"
chown_server_var="$yesno"
if [ "$chown_server_var" = yes ] ; then
chown "$username" "$servinstdir"/server/var "$servinstdir"/server/var/*
if [ $? -ne 0 ] ; then
echo ' '
echo "Whoaaa, this failed, probably it must be done by the superuser."
echo "Please press Return after having entered"
echo ' '
echo " chown $username $servinstdir/server/var $servinstdir/server/var/*"
echo ' '
echo "or if you want to skip this step"
read a
fi
fi
echo ' '
fi
if [ $mode != "clntrem" ] ; then
echo " "
echo "Now we should change the owner of your tape device"
echo "to user $username and grant him exclusive access to it."
echo "You may now enter a filename pattern or no if you"
echo "want to skip this step. Here are the usual streamer"
echo "device name patterns for some OS-es:"
echo " "
echo "Solaris: /dev/rmt/[0-9]*"
echo "AIX: /dev/rmt[0-9]*"
echo "IRIX: /dev/rmt/tps[0-9]*"
echo "HP-UX: /dev/rmt/[0-9]*"
echo "Linux: /dev/st[0-9]* /dev/nst[0-9]*"
echo "Digital UNIX: /dev/rmt[0-9]* /dev/nrmt[0-9]*"
echo "FreeBSD: /dev/rst[0-9]* /dev/nrst[0-9]*"
echo "OpenBSD: /dev/rst[0-9]* /dev/nrst[0-9]*"
case $OSNAME in
SunOS)
osdefdev="/dev/rmt/0*"
;;
AIX)
osdefdev="/dev/rmt0*"
;;
IRIX)
osdefdev="/dev/rmt/tps0d4*"
;;
HPUX)
osdefdev="/dev/rmt/0*"
;;
Linux)
osdefdev="/dev/st0* /dev/nst0*"
;;
OSF1)
osdefdev="/dev/rmt0* /dev/nrmt0*"
;;
FreeBSD)
osdefdev="/dev/sa0* /dev/nsa0*"
;;
OpenBSD)
osdefdev="/dev/rst0* /dev/nrst0*"
;;
*)
osdefdev=""
esac
if [ _"$defdev" = _ ] ; then
defdev="$osdefdev"
fi
echo " "
echo_n "Your choice [$defdev]: "
read c
if [ _"$c" = _ ] ; then
c="$defdev"
fi
if matches _"$c" '^_ye?s?' ; then
c="$osdefdev"
fi
if matches "$c" '^no?$' ; then
:
else
chown "$username" $c
r=$?
chmod 600 $c
r2=$?
if [ $r -ne 0 -o $r2 -ne 0 ] ; then
echo "Oops, this did not work. Please do it manually by "
echo 'entering the following lines:'
echo " "
echo " chown $username $c"
echo " chmod 600 $c"
echo " "
echo "Please hit return when you are done with it or"
echo "want to skip this step."
read c
fi
fi
defdev="$c"
fi
echo ' '
inetdline=`PS1|grep -v grep|grep inetd`
running_inetds=`PS1|grep -v grep|grep inetd|wc -l`
if [ $running_inetds = 0 ] ; then
echo "Sorry, i'm unable to determine the process ID of "
echo 'inetd. Would you do me a favour and enter it here ?'
# askforinetdpid:
while true ; do
echo ' '
echo_n 'Process ID: '
read pid
if matches "$pid" '^[0-9][0-9]*$' ; then
:
else
echo "Invalid input. Please try again."
continue
fi
PS2 $pid >/dev/null 2>&1
if [ $? -eq 0 ] ; then
break
else
echo "This is not the pid of the inetd. Please try again."
fi
done
inetdline=`PS2 $pid|grep -v grep|grep inetd`
fi
if [ $running_inetds -gt 1 ] ; then
echo "Sorry, I found several processes looking like inetd."
echo "Would you please give me a hint and tell me the real"
echo 'process ID ? You may evaluate the following lines:'
echo ' '
PS1|grep -v grep|grep inetd
# askfipid2:
while true ; do
echo ' '
echo_n 'Process ID: '
read pid
if matches "$pid" '^[0-9][0-9]*$' ; then
:
else
echo ' '
echo "Invalid input. Please try again."
continue
fi
PS2 $pid >/dev/null 2>&1
if [ $? -eq 0 ] ; then
break
else
echo ' '
echo "This is not the pid of the inetd. Please try again."
fi
done
inetdline=`PS2 $pid|grep -v grep|grep inetd`
fi
inetdline=`echo "$inetdline"|sed 's/[?*\[]/_/g;s/\]/_/g'`
if [ $running_inetds -eq 1 ] ; then
pid=`echo "$inetdline" | awk '{print $2}'`
fi
echo ' '
echo "The process ID of the inetd seems to be $pid, the"
echo "respective entry in the process list is:"
echo ' '
echo "$inetdline"
echo ' '
if [ $use_xinetd -eq 0 ] ; then
INETDNAME=inetd
SIG="HUP"
else
INETDNAME=xinetd
SIG="USR2"
fi
echo "To activate the backup service we can now send a $SIG signal"
echo_n "to $INETDNAME"'. Do you want to do this ? '
yes_no Yes
c="$yesno"
if [ $c = yes ] ; then
sh -c "kill -$SIG $pid"
if [ $? -ne 0 ] ; then
echo " "
echo "Heyaa, couldn't send signal to the inetd. Probably this"
echo "should be done as the superuser. Please press Return after"
echo "having done it manually by entering 'kill -$SIG $pid'"
echo "or if you want to skip this step."
read a
fi
fi
echo " "
echo "You might now want to move the variable part of the"
if [ $mode = "all" -o $mode = "clntrem" ] ; then
echo_n "backup service"
else
echo_n "server side"
fi
echo " installation to the /var-directory. The"
echo "default directory is $servvarinstdir. If you want to"
echo "do this and this directory is ok, just enter yes. If"
echo 'the directory is not ok, enter the desired one (you'
echo 'may supply the same as for the client side). If you'
echo "want to skip this step, just enter no."
# mvservvar:
while true ; do
echo ' '
echo_n 'Your choice (Yes/No/path) [No]: '
read c
if [ "$c" = "" ] ; then
c="no"
fi
if matches "$c" '^(ye?s?|no?|/.*)$' ; then
break
fi
echo ' '
echo "Invalid choice. Please try again."
done
if matches "$c" '^/' ; then
servvarinstdir="$c"
fi
if matches "$c" '^no?$' ; then
:
else
mkdir -p "$servvarinstdir"
curwd=`pwd`
cd "$servinstdir"/server
if issymlink var ; then
echo "Warning: The directory seems to have already been moved."
echo " Please check where $servinstdir/server/var"
echo " points to. Not moving anything."
else
tar cf - var | (cd "$servvarinstdir"; tar xf -)
mv "$servvarinstdir"/var "$servvarinstdir"/server
/bin/rm -rf var
ln -s "$servvarinstdir"/server var
fi
if [ $mode = "all" -o $mode = "clntrem" ] ; then
cd "$servinstdir"/client
if issymlink var ; then
echo "Warning: The directory seems to have already been moved."
echo " Please check, where $servinstdir/client/var"
echo " points to. Not moving anything."
else
tar cf - var | (cd "$servvarinstdir"; tar xf -)
mv "$servvarinstdir"/var "$servvarinstdir"/client
/bin/rm -rf var
ln -s "$servvarinstdir"/client var
fi
fi
cd "$curwd"
fi
if [ $mode = "all" -o $mode = "servonly" ] ; then
echo ' '
echo "Now we may run the program $servinstdir/server/bin/serverconfig"
echo "so you can configure the server side of the backup system. Would"
echo 'you like to do this now ?'
yes_no "$runserverconfig"
runserverconfig="$yesno"
if matches "$runserverconfig" 'ye?s?' ; then
"$servinstdir"/server/bin/serverconfig
fi
fi
if [ $mode = "all" -o $mode = "clntrem" ] ; then
echo ' '
echo "Now we may run the program $servinstdir/client/bin/clientconfig"
echo "so you can configure the client side of the backup system. Would"
echo 'you like to do this now ?'
yes_no "$runclientconfig"
runclientconfig="$yesno"
if matches "$runclientconfig" 'ye?s?' ; then
"$servinstdir"/client/bin/clientconfig
fi
fi
}
###########################################################################
mult_choice(){
defaultsel="$1"
shift
validchre="$1"
shift
validchoices="$@"
while true ; do
echo " "
echo_n 'Your choice ['"$defaultsel"']: '
read the_choice
if [ _"$the_choice" = _ ] ; then
the_choice="$defaultsel"
fi
if [ _"$validchre" != _ -a _"$validchre" != _- ] ; then
if matches "$the_choice" '^'"$validchre"'$' ; then
break
fi
else
foundch=no
for ch in $validchoices ; do
if [ _"$ch" = _"$the_choice" ] ; then
foundch=yes
fi
done
if [ $foundch = yes ] ; then
break
fi
fi
echo ' '
echo 'This is not a valid choice. Please try again.'
done
}
###########################################################################
choose_DES(){
echo " "
echo "Will we use 128 Bit DES encryption for authenticating the"
echo "client to the server ? (Eric Young's DES library (version"
echo "4.04b or higher) is required and by default expected in the"
echo "directory ../libdes. Alternative is the libcrypto from the"
echo "openssl project (see www.openssl.org). The defaults can be"
echo "modified in the following section, when answering yes. If"
echo "no, the old style encryption is performed."
yes_no $use_des
use_des=$yesno
if [ $use_des = "no" ] ; then
return
fi
configure_options="$configure_options --with-des"
echo " "
echo "Please enter the name of the DES-library's header file"
mult_choice "$des_header" '[^ ]*'
des_header="$the_choice"
echo " "
echo "Please enter the directory where "$des_header" can be found or no,"
echo "if it resides in a place where it is found by default (don't"
echo "supply /usr/include, when comiling with gcc)"
mult_choice "$des_include" '[^ ]*'
des_include="$the_choice"
if matches "$des_include" '^no?$' ; then
des_include="."
else
if [ ! -f $des_include/$des_header ] ; then
echo " "
echo "Warning: File '$des_include/$des_header' does not exist."
fi
fi
configure_options="$configure_options --with-des-include=$des_include"
configure_options="$configure_options --with-des-header=$des_header"
echo " "
echo "Please enter the specifier of the DES-library for linking"
mult_choice "$des_lib" '[^ ]*'
des_lib="$the_choice"
if matches "$des_lib" '^lib' ; then
des_lib=`echo $des_lib|sed 's#^lib#-l#g;s#[.].*##g'`
fi
deslibfile=`echo $des_lib|sed 's#^-l#lib#g'`'.*'
if [ _"$des_libdir" = _ ] ; then
if [ _"$des_include" != _ ] ; then
if [ $des_include = "." ] ; then
des_libdir="no"
else
des_libdir=`echo $des_include|sed 's#/include$#/lib#g'`
fi
else
des_libdir="../libdes"
fi
fi
echo " "
echo "Please enter the directory where the DES library can be found,"
echo "or no if it resides in a place, where it is found by default"
mult_choice "$des_libdir" '[^ ]*'
des_libdir="$the_choice"
if matches "$des_libdir" '^no?$' ; then
des_libdir="."
else
/bin/ls $des_libdir/$deslibfile >/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo " "
echo "Warning: File '$des_libdir/$deslibfile' does not exist."
else
deslibfile=`basename $des_libdir/$deslibfile`
fi
fi
configure_options="$configure_options --with-des-libdir=$des_libdir"
configure_options="$configure_options --with-des-ldflag=$des_lib"
echo " "
echo "Changes in the encryption routines were necessary due to a bug"
echo "in all libdes versions. Thus the newly built programs are unable"
echo "to authenticate successfully with existing installations."
echo "Furthermore if the __descrpt program was used to encrypt files,"
echo "they cannot be decrypted with this program any longer."
echo "Nonetheless it is possible to build the package using the buggy"
echo "function, so backward compatibility for existing installations"
echo "is provided. Should the buggy function be used ?"
yes_no $libdesbug_enabled
libdesbug_enabled=$yesno
}
###########################################################################
choose_ZLIB(){
echo " "
echo "Will we use the libz compression library to have"
echo "built-in compression available ?"
yes_no "$use_zlib"
use_zlib="$yesno"
if [ $yesno = "no" ] ; then
return
fi
configure_options="$configure_options --with-zlib"
echo " "
echo "Please enter the directory where zlib.h can be found or no,"
echo "if it resides in a place where it is found by default (don't"
echo "supply /usr/include when comiling with gcc)"
mult_choice $zlib_include '[^ ]*'
zlib_include="$the_choice"
if matches "$zlib_include" '^no?$' ; then
zlib_include="."
else
if [ ! -f $zlib_include/zlib.h ] ; then
echo " "
echo "Warning: File '$zlib_include/zlib.h' does not exist."
fi
fi
configure_options="$configure_options --with-zlib-include=$zlib_include"
if [ _"$zlib_libdir" = _ ] ; then
if [ _"$zlib_include" != _ ] ; then
if [ $zlib_include = "." ] ; then
zlib_libdir="no"
else
zlib_libdir=`echo $zlib_include|sed 's#/include$#/lib#g'`
fi
else
zlib_libdir="/usr/local/lib"
fi
fi
echo " "
echo "Please enter the directory where the libz library can be found"
echo "or no, if it resides in a place where it is found by default"
mult_choice "$zlib_libdir" '[^ ]*'
zlib_libdir="$the_choice"
if matches "$zlib_libdir" '^no?$' ; then
zlib_libdir="."
else
ls $zlib_libdir/libz.* >/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo " "
echo "Warning: File '$zlib_libdir/libz.*' does not exist."
fi
fi
configure_options="$configure_options --with-zlib-libdir=$zlib_libdir"
}
###########################################################################
choose_threads(){
echo " "
echo "Do you wish to disable threads even if they are"
echo "available on your system? If unsure enter no."
yes_no $disable_threads
disable_threads="$yesno"
if [ $yesno = yes ] ; then
configure_options="$configure_options --disable-threads"
fi
}
###########################################################################
choose_optimization(){
echo " "
echo "On some systems with some compilers high optimization seems to"
echo "corrupt the coded algorithms, so the behaviour of the program is"
echo "not like intended by the programmer. Then it might be desirable"
echo "to reduce the level of optimization. Performance loss should"
echo "be small as most of the time the CPU spends in system calls or"
echo "library functions (e.g. libz calls). Please enter the desired"
echo "compiler flags, if different from the default:"
mult_choice "$optimizer_flags" '.*'
optimizer_flags="$the_choice"
echo ."$optimizer_flags" | grep '^.-' >/dev/null
if [ $? -ne 0 ] ; then
optimizer_flags="-$optimizer_flags"
fi
}
##########################################################################
ask_install(){
echo ' '
echo 'Now we are going to install the software. If you want to'
echo 'stop here for whatever reason, enter no.'
echo ' '
echo_n 'Install the software now ? '
yes_no "$do_install"
do_install="$yesno"
if [ $do_install = no ] ; then
do_exit 0
fi
}
####################################################################
#
# choose appropriate routines for PS1 (display all processes)
# and PS2 (display a certain process)
#
ps -uxawwww >/dev/null 2>&1
if [ $? -eq 0 ] ; then
ps -uxawwww 2>&1 | egrep -i 'bad.*syntax.*bogus' >/dev/null
if [ $? -eq 0 ] ; then
PS1(){
ps uxawwww
}
else
PS1(){
ps -uxawwww
}
fi
else
ps uxawwww >/dev/null 2>&1
if [ $? -eq 0 ] ; then
PS1(){
ps uxawwww
}
else
PS1(){
ps -ef
}
fi
fi
PS2(){
ps1 | awk '$2 = '"$1"' { print $0 }'
}
#################################################################
#
# choose an appropriate routine for echo_n (echo without newline)
#
if [ _`find_program printf` != _ ] ; then
echo_n(){
printf "%s" "$@"
}
else
( echo -n hallo ; echo _ ) | grep '^hallo' >/dev/null
if [ $? -eq 0 ] ; then
echo_n(){
echo -n "$@"
}
else
( echo 'hallo\c' ; echo _ ) | grep 'hallo_$' >/dev/null
if [ $? -eq 0 ] ; then
echo_n(){
echo "$@"'\c'
}
else
echoprog=`find_program echo`
( $echoprog -n hallo ; $echoprog _ ) | grep '^hallo' >/dev/null
if [ $? -eq 0 ] ; then
echo_n(){
$echoprog -n "$@"
}
else
( $echoprog 'hallo\c' ; $echoprog _ ) | grep 'hallo_$' >/dev/null
if [ $? -eq 0 ] ; then
echo_n(){
$echoprog "$@"'\c'
}
else
echo_n(){ # the final crutch
echo "$@" | head -1 | awk '{printf "%s", $0}'
}
fi
fi
fi
fi
fi
######################################################################
#
# extend the path by some directories that according to experience
# contain useful programs
#
pathext=" /usr/bin
/bin
/usr/ccs/bin
/usr/ccs/lib
/opt/gnu/bin
/usr/local/bin
/usr/local/gnu/bin
/opt/bin
/opt/gnu
/opt/GNU/bin
/opt/GNU
/opt/TWWfsw/bin"
for newdir in $pathext ; do
if [ ! -d $newdir ] ; then
continue
fi
found=0
for dir in `echo "$PATH" | tr : ' '` ; do
if [ "$dir" = "$newdir" ] ; then
found=1
break
fi
done
if [ $found -lt 1 ] ; then
PATH="$PATH"":$newdir"
fi
done
export PATH
######################################################
#
# main program
#
CONF_INTERPR=""
if matches "$OSNAME" HPUX ; then
CONF_INTERPR="ksh"
fi
if [ _"$adminprefix" = _ ] ; then
adminprefix="/etc"
fi
inetdfile="$adminprefix/inetd.conf"
use_xinetd=0
xinetd_running=`PS1 | grep -v grep | grep xinetd | wc -l`
if [ -f $adminprefix/xinetd.conf -a $xinetd_running -eq 0 ] ; then
use_xinetd=1
inetdfile="$adminprefix/xinetd.conf"
fi
inetdfile=`resolvepath $inetdfile`
tmpfile="/tmp/core.tmp.$$"
saved_files=""
modes="servonly clntonly clntrem all"
unset GNU_MAKE
THE_MAKE=`which_make`
if [ $? -eq 1 ] ; then
GNU_MAKE="$THE_MAKE"
fi
MAKEOPTS="EXTRA_CFLAGS=-DORIG_DEFAULTS"
MAKECMD="make"
if [ _"$GNU_MAKE" != _ ] ; then
MAKEOPTS="$MAKEOPTS MAKECMD=$GNU_MAKE"
MAKECMD="$GNU_MAKE"
fi
configure_options=""
clear
echo " "
echo 'Welcome to the installation procedure for'
echo " "
echo "AF's backup system *"
echo '===================='
echo " "
echo ' '
echo 'You can interrupt this program any time hitting Ctrl-C. For the'
echo 'most of the following questions a default answer is offered in'
echo "square brackets. If you don't want to change this or if you are"
echo "unsure, it is quite safe to confirm the offered choice, so please"
echo "feel free to just hit the Return key."
echo " "
echo "First you have to decide, which functionality you"
echo 'would like to have on this machine.'
echo " "
echo '(1) Backup server only'
echo '(2) Backup client only (also to start backups on other hosts)'
echo '(3) Backup client only with remote start option'
echo '(4) Backup server, client and client remote start option'
echo " "
sel=0
while true ; do
if matches "$sel" '^[1-4]$' ; then
break
fi
echo_n 'Please enter your choice [1-4]: '
read sel
if matches "$sel" '^[1-4]$' ; then
:
else
echo "This is not a valid choice. Please try again."
echo " "
fi
done
mode=`echo "$modes" | awk '{print $'$sel'}'`
if matches "$OSNAME" SunOS || matches "$OSNAME" HPUX ; then
the_gcc=`find_program gcc`
echo ' '
echo 'Shall we use gcc to build afbackup (strongly recommended) ?'
defaultusegcc="Yes"
if [ `echo $the_gcc | wc -w` -lt 1 ] ; then
echo '(Unfortunately gcc is not found in the current $PATH)'
defaultusegcc="No"
fi
if [ _"$usegcc" = _ ] ; then
usegcc="$defaultusegcc"
fi
yes_no $usegcc
usegcc="$yesno"
if [ $usegcc = yes ] ; then
CC="gcc"
export CC
fi
fi
for SIG in INT TERM ABRT HUP BUS PIPE ; do
SIGNUM=`signalbyname $SIG`
if [ _"$SIGNUM" != _ ] ; then
trap "intrexit $SIGNUM" $SIGNUM
fi
done
case "$sel" in
1)
server_only
;;
2)
client_only
;;
3)
remclient
;;
4)
all
;;
esac
echo " "
if [ $mode = client_only -o $mode = remclient -o $mode = all ] ; then
echo "When the server has been configured properly, the following"
echo "commands can be used to do backup, verify and restore (all"
echo "in $clntinstdir/client/bin):"
echo " full_backup to make a full backup"
echo " incr_backup to make an incremental backup"
echo " afverify to verify the latest backup"
echo " afrestore ... to make restores"
echo "For more information see the INTRO file and the manual pages."
fi
echo 'All done. The input supplied during this installation procedure'
echo 'is saved in the file "Install.cache". This file can be copied'
echo 'somewhere else to have the input present as default for the next'
echo 'upgrade or installation on other architectures. The file will be'
echo 'erased when you do a "make distclean".'
if [ `echo $saved_files | wc -w` -gt 0 ] ; then
echo " "
echo "The following files are safety copies of files, that"
echo "are crucial for your system. If up to now everything"
echo "worked fine then you can safely remove them:"
echo " "
echo $saved_files
echo ' '
fi
do_exit 0
|