100 lines
3.7 KiB
Bash
Executable File
100 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
. ./myserver.conf
|
|
|
|
|
|
install_prosody_package(){
|
|
|
|
pkg_add prosody
|
|
ln -sf /usr/local/bin/luarocks-5.3 /usr/local/bin/luarocks
|
|
ln -sf /usr/local/bin/luarocks-admin-5.3 /usr/local/bin/luarocks-admin
|
|
|
|
}
|
|
|
|
gen_prosody_configuration(){
|
|
|
|
cp -v default_configuration/xmpp/prosody.cfg.lua.example default_configuration/xmpp/prosody.cfg.lua
|
|
sed -i "s/__DOMAIN__/$DOMAIN/g" default_configuration/xmpp/prosody.cfg.lua
|
|
cp -v default_configuration/xmpp/virtualHosts/example.com.conf default_configuration/xmpp/virtualHosts/$DOMAIN.conf
|
|
sed -i "s/__DOMAIN__/$DOMAIN/g" default_configuration/xmpp/virtualHosts/$DOMAIN.conf
|
|
sed -i "s/__xmpp_passphrase_for_filesuploads__/$xmpp_passphrase_for_filesuploads/g" default_configuration/xmpp/virtualHosts/$DOMAIN.conf
|
|
|
|
|
|
}
|
|
|
|
install_xmpp_certs_ssl(){
|
|
|
|
openssl dhparam -out my_configuration/xmpp/dh-2048.pem 2048
|
|
install -o _prosody -g _prosody my_configuration/xmpp/dh-2048.pem /etc/prosody/certs/dh-2048.pem
|
|
install -o _prosody -g _prosody /etc/ssl/private/"$DOMAIN".key /etc/prosody/certs/"$DOMAIN".key;
|
|
install -o _prosody -g _prosody /etc/ssl/"$DOMAIN".crt /etc/prosody/certs/"$DOMAIN".crt;
|
|
|
|
}
|
|
|
|
install_prosody_modules(){
|
|
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_cloud_notify
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_cloud_notify_extensions
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_muc_mam
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_muc_log
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_http_upload_external
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_muc_limits
|
|
prosodyctl install --server=https://modules.prosody.im/rocks/ mod_vcard_muc
|
|
|
|
}
|
|
|
|
|
|
gen_nginx_configuration_files_upload(){
|
|
|
|
cp -v default_configuration/xmpp/nginx.conf.sample my_configuration/xmpp/upload.$DOMAIN
|
|
cp -v default_configuration/xmpp/share.php.sample my_configuration/xmpp/share.php
|
|
sed -i "s/__DOMAIN__/$DOMAIN/g" my_configuration/xmpp/upload.$DOMAIN
|
|
sed -i "s/__DOMAIN__/$DOMAIN/" my_configuration/xmpp/share.php
|
|
sed -i "s/__xmpp_passphrase_for_filesuploads__/$xmpp_passphrase_for_filesuploads/g" my_configuration/xmpp/share.php
|
|
|
|
}
|
|
|
|
add_logs_to_newsyslog(){
|
|
|
|
egrep -v "prosody" /etc/newsyslog.conf > /tmp/newsyslog.conf
|
|
echo '/var/prosody/prosody.log _prosody:_prosody 640 2 * $W0 Z /var/prosody/prosody.pid SIGUSR1' >> /tmp/newsyslog.conf
|
|
echo '/var/prosody/prosody.err _prosody:_prosody 640 2 250 * Z /var/proosody/prosody.pid SIGUSR1' >> /tmp/newsyslog.conf
|
|
mv /tmp/newsyslog.conf /etc/newsyslog.conf
|
|
}
|
|
|
|
install_nginx_configuration_files_upload(){
|
|
|
|
mkdir -p /var/www/xmpp-upload/$DOMAIN/upload
|
|
chown -R www:daemon /var/www/xmpp-upload/
|
|
cp my_configuration/xmpp/upload.$DOMAIN /etc/nginx/sites-available/
|
|
ln -s /etc/nginx/sites-available/upload.$DOMAIN /etc/nginx/sites-enabled/upload.$DOMAIN
|
|
cp my_configuration/xmpp/share.php /var/www/xmpp-upload/
|
|
|
|
}
|
|
|
|
install_xmpp_configurations_files(){
|
|
|
|
cp -v my_configuration/xmpp/prosody.cfg.lua /etc/prosody/prosody.cfg.lua
|
|
mkdir /etc/prosody/virtualHosts
|
|
cp -v my_configuration/xmpp/virtualHosts/$DOMAIN.conf /etc/prosody/virtualHosts/$DOMAIN.conf
|
|
|
|
}
|
|
|
|
|
|
mkdir my_configuration/xmpp
|
|
if [ "$1" == "gen-config-only" ];
|
|
then
|
|
gen_prosody_configuration
|
|
gen_nginx_configuration_files_upload
|
|
elif [ "$1" == "install" ];
|
|
then
|
|
gen_prosody_configuration
|
|
gen_nginx_configuration_files_upload
|
|
install_prosody_package
|
|
install_prosody_modules
|
|
install_xmpp_configurations_files
|
|
install_xmpp_certs_ssl
|
|
rcctl enable prosody
|
|
rcctl start prosody
|
|
fi
|