Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active April 4, 2024 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jniltinho/b2f51c013dd963b7c0769a615be6e21e to your computer and use it in GitHub Desktop.
Save jniltinho/b2f51c013dd963b7c0769a615be6e21e to your computer and use it in GitHub Desktop.
Install Znuny 7 --> New OTRS Community Edition
#!/bin/bash
## Install Znuny 7.0.16 on Ubuntu 22.04
## https://doc.znuny.org/znuny_lts/releases/installupdate/install.html
## https://itgovernanceportal.com/otrs/otrs-znuny-ubuntu-nginx/?cn-reloaded=1
## https://download.znuny.org/releases/znuny-7.0.16.tar.gz
## Run as root (sudo su)
cd /opt
wget https://download.znuny.org/releases/znuny-7.0.16.tar.gz
tar xfz znuny-7.0.16.tar.gz
mv /opt/znuny-7.0.16 /opt/znuny
useradd -d /opt/znuny -c 'Znuny user' -g www-data -s /bin/bash -M -N znuny
#usermod -a -G www-data znuny
# Copy Default Config
cp /opt/znuny/Kernel/Config.pm.dist /opt/znuny/Kernel/Config.pm
# As otrs User - Rename default cronjobs
cd /opt/znuny/var/cron
for foo in *.dist; do cp $foo `basename $foo .dist`; done
/opt/znuny/bin/znuny.SetPermissions.pl --znuny-user=znuny --web-group=www-data
apt -y install nginx fcgiwrap mariadb-client mariadb-server cpanminus libdbd-mysql-perl
apt -y install libtimedate-perl libnet-dns-perl libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl
apt -y install libsoap-lite-perl libtext-csv-xs-perl libjson-xs-perl libxml-libxml-perl
apt -y install libxml-libxslt-perl libyaml-perl libarchive-zip-perl libcrypt-eksblowfish-perl libencode-hanextra-perl
apt -y install libmail-imapclient-perl libtemplate-perl libdatetime-perl libmoo-perl bash-completion
apt -y install libyaml-libyaml-perl libjavascript-minifier-xs-perl libcss-minifier-xs-perl libauthen-sasl-perl
apt -y install libauthen-ntlm-perl libhash-merge-perl libical-parser-perl libspreadsheet-xlsx-perl libcrypt-jwt-perl
apt -y install libcrypt-openssl-x509-perl jq
cpanm install Jq
cat <<'EOF' >/etc/mysql/mariadb.conf.d/50-znuny_config.cnf
[mysql]
max_allowed_packet=256M
[mysqldump]
max_allowed_packet=256M
[mysqld]
innodb_file_per_table
innodb_log_file_size = 256M
max_allowed_packet=256M
character-set-server = utf8
collation-server = utf8_general_ci
EOF
mysql_secure_installation
service mysql restart
#/opt/znuny/bin/znuny.SetPermissions.pl --znuny-user=znuny --web-group=www-data
#/opt/znuny/bin/znuny.CheckModules.pl
#perl -cw /opt/znuny/bin/cgi-bin/index.pl
#perl -cw /opt/znuny/bin/cgi-bin/customer.pl
#perl -cw /opt/znuny/bin/znuny.Console.pl
## Start Daemon Cron
cd /opt/znuny/var/cron
for foo in *.dist; do cp $foo `basename $foo .dist`; done
#chown -R znuny:www-data /opt/znuny
su -c "/opt/znuny/bin/Cron.sh start" -s /bin/bash znuny
su -c "/opt/znuny/bin/znuny.Daemon.pl start" -s /bin/bash znuny
systemctl enable mariadb nginx fcgiwrap
systemctl start fcgiwrap
chmod 766 /var/run/fcgiwrap.socket
cat <<'EOF' >/etc/systemd/system/znuny.service
[Unit]
Description=Start Znuny Daemon Service
ConditionPathExists=/opt/znuny
After=network.target
[Service]
Type=forking
User=znuny
#Group=www-data
WorkingDirectory=/opt/znuny
ExecStart=/opt/znuny/bin/znuny.Daemon.pl start
Restart=on-failure
RestartSec=10
StandardOutput=append:/opt/znuny/znuny.log
StandardError=append:/opt/znuny/znuny.log
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable znuny.service
systemctl start znuny.service
## To complete the installation, configure Znuny in your browser
## http://<server_ip>/znuny/installer.pl
## DB: znuny, USER: znuny, PASSWD: znuny-pass
server {
server_name _;
access_log /var/log/znuny-access.log;
error_log /var/log/znuny-error.log;
# prevent buffer problems in OTRS
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
# Enter your htdocs path here, e.g. /opt/znuny/var/httpd/htdocs
root /opt/znuny/var/httpd/htdocs;
# Do not log favicon access
location = /favicon.ico {
access_log off;
log_not_found off;
}
location /znuny-web {
alias /opt/znuny/var/httpd/htdocs;
}
location ~ ^/(?:otrs|znuny)/(.*\.pl)(/.*)?$ {
gzip off;
# Enter your fcgiwrap socket here
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
# Enter your OTRS cgi-bin path, e.g. /opt/znuny/bin/cgi-bin
fastcgi_param SCRIPT_FILENAME /opt/znuny/bin/cgi-bin/$1;
include znuny_fastcgi_params;
}
}
## /etc/nginx/znuny_fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment