Guest User

Untitled

a guest
Apr 5th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # SET A FQDN
  4. FQDN=openkm.centos.com
  5. hostname $FQDN
  6. echo $FQDN > /etc/hostname
  7. echo "127.0.0.1 $FQDN" >> /etc/hosts
  8.  
  9.  
  10. # Download the epel repo
  11. yum install epel-release -y
  12.  
  13. # Download the openkm .run file and execute it
  14. cd /tmp
  15. wget http://sourceforge.net/projects/openkm/files/6.3/openkm-6.3.0-community-linux-x64-installer.run
  16. chmod 700 ./openkm-6.3.0-community-linux-x64-installer.run
  17. ./openkm-6.3.0-community-linux-x64-installer.run
  18.  
  19. .#http://www.openkm.com/en/download-english.html, make expect wrapper for wizard
  20.  
  21.  
  22.  
  23. # Download the ClamAV antivirus package
  24. yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd -y
  25.  
  26. # Enable antivirus_can_scan_System
  27. setsebool -P antivirus_can_scan_system 1
  28.  
  29. # Copy the configuration template into place
  30. cp /usr/share/clamav/template/clamd.conf /etc/clamd.d/clamd.conf
  31. sed -i '/^Example/d' /etc/clamd.d/clamd.conf
  32.  
  33. # Set ClamAV to run as root
  34. sed -i 's/<USER>/root/' /etc/clamd.d/clamd.conf
  35.  
  36. # Create sock file
  37. mkdir /var/run/clamd.d
  38. sed -i 's/<SERVICE>/d/' /etc/clamd.d/clamd.conf
  39.  
  40. # Enable freshclam
  41. cp /etc/freshclam.conf /etc/freshclam.conf.bak
  42. sed -i '/^Example/d' /etc/freshclam.conf
  43.  
  44. # Create systemd file to start freshclam on boot
  45. cat <<EOF >> /usr/lib/systemd/system/clam-freshclam.service
  46. # Run the freshclam as daemon
  47. [Unit]
  48. Description = freshclam scanner
  49. After = network.target
  50. [Service]
  51. Type = forking
  52. ExecStart = /usr/bin/freshclam -d -c 4
  53. Restart = on-failure
  54. PrivateTmp = true
  55. [Install]
  56. WantedBy=multi-user.target
  57. EOF
  58.  
  59. # Configure freshclam to run on boot
  60. systemctl enable clam-freshclam
  61.  
  62. # Start freshclam
  63. systemctl start clam-freshclam
  64.  
  65. # Make some needed changes to the service files for them to be usable
  66. rm /usr/lib/systemd/system/clamd@.service
  67. sed -i 's/clamd\@\.service/clamd\.service/' /usr/lib/systemd/system/clamd\@scan.service
  68. cat <<EOF >> /usr/lib/systemd/system/clamd.service
  69. [Unit]
  70. Description = clamd scanner daemon
  71. After = syslog.target nss-lookup.target network.target
  72. [Service]
  73. Type = simple
  74. ExecStart = /usr/sbin/clamd -c /etc/clamd.d/clamd.conf --nofork=yes
  75. Restart = on-failure
  76. PrivateTmp = true
  77. [Install]
  78. WantedBy=multi-user.target
  79. EOF
  80. chkconfig --levels 235 amavisd on
  81. chkconfig --levels 235 clamd on
  82. systemctl start amavisd
  83. systemctl start clamd
  84. mkidr /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db
  85. chown amavis /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db
  86. ln -s /var/run/clamd.d/clamd.sock /var/spool/amavisd/clamd.sock
  87.  
  88.  
  89.  
  90. # Move into the service directory
  91. cd /usr/lib/systemd/system
  92. systemctl enable clamd.service
  93. systemctl enable clamd@scan.service
  94. systemctl start clamd.service
  95. systemctl start clamd@scan.service
  96.  
  97. # Install needed packages
  98. yum install -y ImageMagick libjpeg-devel libpng-devel libtiff-devel zlib-devel gcc gcc-c++ make autoconf libtool automake gcc* libreoffice* automake zlib-devel libjpeg-devel giflib-devel freetype-devel ImageMagick amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql java-1.8.0-openjdk-devel.x86_64 libjpeg-devel libpng-devel libtiff-devel zlib-devel gcc gcc-c++ make autoconf libtool automake tesseract giflib-devel freetype-devel python-xvfbwrapper
  99.  
  100. # Configure libreoffice
  101. ln -s /usr/lib64/libreoffice /usr/lib/libreoffice
  102. cd /tmp
  103. wget ftp://195.220.108.108/linux/centos/7.2.1511/os/x86_64/Packages/libXext-1.3.3-3.el7.i686.rpm
  104. wget ftp://195.220.108.108/linux/centos/7.2.1511/os/x86_64/Packages/libSM-1.2.2-2.el7.i686.rpm
  105. yum localinstall ./libXext-1.3.3-3.el7.i686.rpm ./libSM-1.2.2-2.el7.i686.rpm -y
  106. /usr/lib/openoffice/program/soffice -headless -accept="socket,host=127.0.0.1,port=2002;urp;" -nofirststartwizard &
  107.  
  108. # Download and install swftools
  109. cd /tmp
  110. wget http://swftools.org/swftools-0.9.2.tar.gz
  111. tar xzf swftools-0.9.2.tar.gz
  112. cd swftools-0.9.2
  113. ./configure && make && make install
  114. cd ..
  115.  
  116. # Configure OpenKM.cfg
  117. ln -s /opt/openkm-6.3.0-community/tomcat /opt/openkm
  118. echo <<EOF >> /opt/openkm/OpenKM.cfg
  119. system.ocr=/usr/bin/tesseract
  120. system.openoffice.server=http://localhost:8080/converter/convert
  121. system.imagemagick.convert =/usr/bin/convert
  122. system.swftools.pdf2swf = /usr/local/bin/pdf2swf -T 9 -f ${fileIn} -o ${fileOut}
  123. system.antivir=/usr/bin/clamscan
  124. hibernate.dialect=org.hibernate.dialect.HSQLDialect
  125. hibernate.hbm2ddl=none
  126. application.url=http://$FQDN:8080/OpenKM/com.openkm.frontend.Main/index.jsp
  127. system.webdav.server=on
  128. system.webdav.fix=on
  129. EOF
  130.  
  131. # Configure tomcat to allow external connections
  132. sed -i 's/127\.0\.0\.1/0\.0\.0\.0/' /opt/openkm/conf/server.xml
  133.  
  134. # Install nodejs
  135. curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
  136. yum install -y nodejs
  137.  
  138. wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/7/x86_64/n/nodejs-unicode-7.0.0-0.1.5-2.el7.noarch.rpm
  139. yum localinstall nodejs-unicode-7.0.0-0.1.5-2.el7.noarch.rpm -y
  140.  
  141. wget ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/18/Everything/x86_64/os/Packages/c/cuneiform-1.1.0-9.fc18.x86_64.rpm
  142.  
  143. yum localinstall cuneiform-1.1.0-9.fc18.x86_64.rpm -y
  144.  
  145. # Start tomcat
  146. cd /opt/openkm/bin
  147. ./catalina.sh start
  148.  
  149.  
  150. echo 'You can access OpenKM at http://your-domain.com:8080/OpenKM'
  151. echo 'The default credentials are username: okmAdmin, password: admin'
  152. echo 'To get image OCR working, set system.ocr to /usr/bin/tesseract and append com.openkm.extractor.Tesseract3TextExtractor to registered.text.extractors'
Add Comment
Please, Sign In to add comment