Skip to content
Snippets Groups Projects
Commit b62ccfd3 authored by Bob Mottram's avatar Bob Mottram
Browse files

Tidying

parent 608d84fd
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,66 @@ xmpp_variables=(ONION_ONLY
DEFAULT_DOMAIN_NAME
XMPP_DOMAIN_CODE)
function prosody_remove_module_from_config {
remove_prosody_module_name="$1"
prosody_config_file="$2"
if [ ! "${remove_prosody_module_name}" ]; then
return
fi
if [ ! -f "${prosody_config_file}" ]; then
echo "Config file ${prosody_config_file} not found when removing module $remove_prosody_module_name"
return
fi
if grep -q "\"${remove_prosody_module_name}\"" "${prosody_config_file}"; then
sed -i "/\"${remove_prosody_module_name}\"/d" "${prosody_config_file}"
xmpp_restart=1
fi
}
function prosody_remove_module {
remove_prosody_module_name="$1"
prosody_remove_module_from_config "${remove_prosody_module_name}" /etc/prosody/prosody.cfg.lua
prosody_remove_module_from_config "${remove_prosody_module_name}" /etc/prosody/conf.avail/xmpp.cfg.lua
}
function prosody_add_module_to_config {
new_prosody_module_name="$1"
prosody_config_file="$2"
add_to_muc="$3"
if [ ! "${new_prosody_module_name}" ]; then
return
fi
if [ ! -f "${prosody_config_file}" ]; then
echo "Config file ${prosody_config_file} not found when adding module $new_prosody_module_name"
return
fi
if ! grep -q "\"${new_prosody_module_name}\"" "$prosody_config_file"; then
sed -i "/\"pep\"/a \"${new_prosody_module_name}\";" "$prosody_config_file"
if [ "$add_to_muc" ]; then
if grep -q "\"muc_limits\"" "$prosody_config_file"; then
sed -i "/\"muc_limits\"/a \"${new_prosody_module_name}\";" "$prosody_config_file"
fi
fi
sed -i "s|\"${new_prosody_module_name}\"| \"${new_prosody_module_name}\"|g" "$prosody_config_file"
xmpp_restart=1
fi
}
function prosody_add_module {
new_prosody_module_name="$1"
add_to_muc="$2"
prosody_add_module_to_config "${new_prosody_module_name}" /etc/prosody/prosody.cfg.lua "$add_to_muc"
prosody_add_module_to_config "${new_prosody_module_name}" /etc/prosody/conf.avail/xmpp.cfg.lua "$add_to_muc"
}
function xmpp_fix_exists {
if ! grep -q "CREATE INDEX IF NOT EXISTS" plugins/mod_storage_sql1.lua; then
sed -i 's|CREATE INDEX|CREATE INDEX IF NOT EXISTS|g' plugins/mod_storage_sql1.lua
......@@ -552,32 +612,9 @@ function update_prosody_modules {
fi
fi
if ! grep -q "s2s_blacklist" /etc/prosody/conf.avail/xmpp.cfg.lua; then
sed -i '/"pep";/a "s2s_blacklist"; -- Block bad domains' /etc/prosody/conf.avail/xmpp.cfg.lua
sed -i 's|"s2s_blacklist";| "s2s_blacklist";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
xmpp_restart=1
fi
if ! grep -q "\"firewall\"" /etc/prosody/conf.avail/xmpp.cfg.lua; then
sed -i '/"pep";/a "firewall"; -- Block addresses' /etc/prosody/conf.avail/xmpp.cfg.lua
sed -i 's|"firewall";| "firewall";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
xmpp_restart=1
fi
if ! grep -q "s2s_blacklist" /etc/prosody/prosody.cfg.lua; then
sed -i '/"pep";/a "s2s_blacklist"; -- Block bad domains' /etc/prosody/prosody.cfg.lua
sed -i 's|"s2s_blacklist";| "s2s_blacklist";|g' /etc/prosody/prosody.cfg.lua
xmpp_restart=1
fi
if ! grep -q "s2s_blacklist" /etc/prosody/prosody.cfg.lua; then
sed -i '/"pep";/a "s2s_blacklist"; -- Block bad domains' /etc/prosody/prosody.cfg.lua
sed -i '/"muc_limits";/a "s2s_blacklist";' /etc/prosody/prosody.cfg.lua
sed -i 's|"s2s_blacklist";| "s2s_blacklist";|g' /etc/prosody/prosody.cfg.lua
xmpp_restart=1
fi
if ! grep -q "\"firewall\"" /etc/prosody/prosody.cfg.lua; then
sed -i '/"pep";/a "firewall"; -- Block addresses' /etc/prosody/prosody.cfg.lua
sed -i 's|"firewall";| "firewall";|g' /etc/prosody/prosody.cfg.lua
xmpp_restart=1
fi
prosody_add_module 's2s_blacklist' muc
prosody_add_module 'firewall'
prosody_add_module 'block_strangers'
xmpp_server_blacklist /etc/prosody/prosody.cfg.lua
......@@ -585,17 +622,6 @@ function update_prosody_modules {
sed -i '/"mam_muc";/d' /etc/prosody/prosody.cfg.lua
xmpp_restart=1
fi
if ! grep -q "block_strangers" /etc/prosody/conf.avail/xmpp.cfg.lua; then
sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/conf.avail/xmpp.cfg.lua
sed -i 's|"block_strangers";| "block_strangers";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
xmpp_restart=1
fi
if ! grep -q "block_strangers" /etc/prosody/prosody.cfg.lua; then
sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/prosody.cfg.lua
sed -i 's|"block_strangers";| "block_strangers";|g' /etc/prosody/prosody.cfg.lua
xmpp_restart=1
fi
}
function prosody_daemon_restart_script {
......@@ -658,57 +684,6 @@ function upgrade_xmppsend {
}
function prosody_remove_module_from_config {
remove_prosody_module_name="$1"
prosody_config_file="$2"
if [ ! "${remove_prosody_module_name}" ]; then
return
fi
if [ ! -f "${prosody_config_file}" ]; then
echo "Config file ${prosody_config_file} not found when removing module $remove_prosody_module_name"
return
fi
if grep -q "\"${remove_prosody_module_name}\"" "${prosody_config_file}"; then
sed -i "/\"${remove_prosody_module_name}\"/d" "${prosody_config_file}"
xmpp_restart=1
fi
}
function prosody_remove_module {
remove_prosody_module_name="$1"
prosody_remove_module_from_config "${remove_prosody_module_name}" /etc/prosody/prosody.cfg.lua
prosody_remove_module_from_config "${remove_prosody_module_name}" /etc/prosody/conf.avail/xmpp.cfg.lua
}
function prosody_add_module_to_config {
new_prosody_module_name="$1"
prosody_config_file="$2"
if [ ! "${new_prosody_module_name}" ]; then
return
fi
if [ ! -f "${prosody_config_file}" ]; then
echo "Config file ${prosody_config_file} not found when adding module $new_prosody_module_name"
return
fi
if ! grep -q "\"${new_prosody_module_name}\"" "$prosody_config_file"; then
sed -i "/\"pep\"/a \"${new_prosody_module_name}\";" "$prosody_config_file"
sed -i "s|\"${new_prosody_module_name}\"| \"${new_prosody_module_name}\"|g" "$prosody_config_file"
xmpp_restart=1
fi
}
function prosody_add_module {
new_prosody_module_name="$1"
prosody_add_module_to_config "${new_prosody_module_name}" /etc/prosody/prosody.cfg.lua
prosody_add_module_to_config "${new_prosody_module_name}" /etc/prosody/conf.avail/xmpp.cfg.lua
}
function upgrade_xmpp {
xmpp_restart=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment