@@ -389,7 +389,7 @@ install_template() {
389389 local chmod="${pos_args[4]-644}"
390390
391391 info_msg "install (eval=$do_eval): ${dst}"
392− [[ -n $variant ]] && info_msg "variant: ${variant}"
392+ [[ -n $variant ]] && info_msg "variant --> ${variant}"
393393
394394 if [[ ! -f "${template_origin}" ]] ; then
395395 err_msg "${template_origin} does not exists"
@@ -777,6 +777,7 @@ apache_dissable_site() {
777777 ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
778778 ;;
779779 esac
780+ apache_reload
780781}
781782
782783# uWSGI
@@ -846,7 +847,7 @@ uWSGI_restart() {
846847 if uWSGI_app_available "${CONF}"; then
847848 systemctl restart "uwsgi@${CONF%.*}"
848849 else
849− info_msg "in systemd template mode: ${CONF} not installed (nothing to restart)"
850+ info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
850851 fi
851852 ;;
852853 fedora-*)
@@ -854,7 +855,7 @@ uWSGI_restart() {
854855 if uWSGI_app_enabled "${CONF}"; then
855856 touch "${uWSGI_APPS_ENABLED}/${CONF}"
856857 else
857− info_msg "in uWSGI emperor mode: ${CONF} not installed (nothing to restart)"
858+ info_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"
858859 fi
859860 ;;
860861 *)
@@ -864,6 +865,32 @@ uWSGI_restart() {
864865 esac
865866}
866867
868+uWSGI_prepare_app() {
869+
870+ # usage: uWSGI_prepare_app <myapp.ini>
871+
872+ local APP="${1%.*}"
873+ if [[ -z $APP ]]; then
874+ err_msg "uWSGI_prepare_app: missing arguments"
875+ return 42
876+ fi
877+
878+ case $DIST_ID-$DIST_VERS in
879+ fedora-*)
880+ # in emperor mode, the uwsgi user is the owner of the sockets
881+ info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}"
882+ mkdir -p "/run/uwsgi/app/${APP}"
883+ chown -R "uwsgi:uwsgi" "/run/uwsgi/app/${APP}"
884+ ;;
885+ *)
886+ info_msg "prepare (${SERVICE_USER}:${SERVICE_GROUP}) /run/uwsgi/app/${APP}"
887+ mkdir -p "/run/uwsgi/app/${APP}"
888+ chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "/run/uwsgi/app/${APP}"
889+ ;;
890+ esac
891+}
892+
893+
867894uWSGI_app_available() {
868895 # usage: uWSGI_app_available <myapp.ini>
869896 local CONF="$1"
@@ -888,6 +915,7 @@ uWSGI_install_app() {
888915 *) pos_args+=("$i");;
889916 esac
890917 done
918+ uWSGI_prepare_app "${pos_args[1]}"
891919 mkdir -p "${uWSGI_APPS_AVAILABLE}"
892920 install_template "${template_opts[@]}" \
893921 "${uWSGI_APPS_AVAILABLE}/${pos_args[1]}" \
@@ -1281,3 +1309,30 @@ global_IPs(){
12811309
12821310 ip -o addr show | sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\1|\2/p'
12831311}
1312+
1313+primary_ip() {
1314+
1315+ case $DIST_ID in
1316+ arch)
1317+ echo "$(ip -o addr show \
1318+ | sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' \
1319+ | head -n 1)"
1320+ ;;
1321+ *) echo "$(hostname -I | cut -d' ' -f1)" ;;
1322+ esac
1323+}
1324+
1325+# URL
1326+# ---
1327+
1328+url_replace_hostname(){
1329+
1330+ # usage: url_replace_hostname <url> <new hostname>
1331+
1332+ # to replace hostname by primary IP::
1333+ #
1334+ # url_replace_hostname http://searx-ubu1604/morty $(primary_ip)
1335+ # http://10.246.86.250/morty
1336+
1337+ echo "$1" | sed "s|\(http[s]*://\)[^/]*\(.*\)|\1$2\2|"
1338+}