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

gettogether seemed like a nice idea but uses a third party geolocator called...

gettogether seemed like a nice idea but uses a third party geolocator called ipstack. That will obviously leak location data to an entity outside of user/community control and so is probably unwise
parent b3673ccb
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
#
# Freedom in the Cloud
#
# A Meetup style app
#
# License
# =======
#
# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
VARIANTS='full full-vim'
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
GETTOGETHER_DOMAIN_NAME=
GETTOGETHER_CODE=
GETTOGETHER_ONION_PORT=9492
GETTOGETHER_REPO="https://github.com/GetTogetherComm/GetTogether"
GETTOGETHER_COMMIT='a3a37ee689ece3c37cadbacb5678fce4d7d7b00e'
GETTOGETHER_PORT_INTERNAL=8652
# These parameters are used by the FreedomBox mobile app
GETTOGETHER_SHORT_DESCRIPTION='Get Together'
GETTOGETHER_DESCRIPTION='Create events for meetups'
GETTOGETHER_MOBILE_APP_URL=
gettogether_variables=(ONION_ONLY
GETTOGETHER_DOMAIN_NAME
GETTOGETHER_CODE
DDNS_PROVIDER
MY_USERNAME)
function logging_on_gettogether {
echo -n ''
}
function logging_off_gettogether {
echo -n ''
}
function remove_user_gettogether {
remove_username="$1"
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp gettogether
}
function add_user_gettogether {
new_username="$1"
new_user_password="$2"
"${PROJECT_NAME}-pass" -u "$new_username" -a gettogether -p "$new_user_password"
echo '0'
}
function install_interactive_gettogether {
if [ ! "$ONION_ONLY" ]; then
ONION_ONLY='no'
fi
if [[ "$ONION_ONLY" != "no" ]]; then
GETTOGETHER_DOMAIN_NAME='gettogether.local'
write_config_param "GETTOGETHER_DOMAIN_NAME" "$GETTOGETHER_DOMAIN_NAME"
else
interactive_site_details "gettogether" "GETTOGETHER_DOMAIN_NAME" "GETTOGETHER_CODE"
fi
APP_INSTALLED=1
}
function change_password_gettogether {
curr_username="$1"
new_user_password="$2"
read_config_param 'GETTOGETHER_DOMAIN_NAME'
"${PROJECT_NAME}-pass" -u "$curr_username" -a gettogether -p "$new_user_password"
}
function reconfigure_gettogether {
# This is used if you need to switch identity. Dump old keys and generate new ones
echo -n ''
}
function configure_interactive_gettogether {
W=(1 $"Option 1"
2 $"Option 2")
while true
do
# shellcheck disable=SC2068
selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"gettogether" --menu $"Choose an operation, or ESC for main menu:" 14 70 3 "${W[@]}" 3>&2 2>&1 1>&3)
if [ ! "$selection" ]; then
break
fi
case $selection in
1) # call some function for option 1
;;
2) # call some function for option 2
;;
esac
done
}
function upgrade_gettogether {
CURR_GETTOGETHER_COMMIT=$(get_completion_param "gettogether commit")
if [[ "$CURR_GETTOGETHER_COMMIT" == "$GETTOGETHER_COMMIT" ]]; then
return
fi
if grep -q "gettogether domain" "$COMPLETION_FILE"; then
GETTOGETHER_DOMAIN_NAME=$(get_completion_param "gettogether domain")
fi
systemctl stop gettogether
# update to the next commit
set_repo_commit "/etc/gettogether" "gettogether commit" "$GETTOGETHER_COMMIT" "$GETTOGETHER_REPO"
cd "/etc/gettogether" || exit 3463754637
./env/bin/pip install -r requirements.txt
./env/bin/python manage.py migrate
if [ -f /root/freedombone/image_build/countryinfo.txt ]; then
./env/bin/python manage.py load_countries /root/freedombone/image_build/countryinfo.txt
fi
if [ -f /root/freedombone/image_build/codesascii.txt ]; then
./env/bin/python manage.py load_spr /root/freedombone/image_build/codesascii.txt
fi
chown -R gettogether:gettogether "/etc/gettogether"
systemctl restart gettogether
}
function backup_local_gettogether {
GETTOGETHER_DOMAIN_NAME='gettogether'
if grep -q "gettogether domain" "$COMPLETION_FILE"; then
GETTOGETHER_DOMAIN_NAME=$(get_completion_param "gettogether domain")
fi
source_directory=/etc/gettogether
suspend_site "${GETTOGETHER_DOMAIN_NAME}"
systemctl stop gettogether
dest_directory=gettogether
backup_directory_to_usb "$source_directory" $dest_directory
restart_site
systemctl start gettogether
}
function restore_local_gettogether {
if ! grep -q "gettogether domain" "$COMPLETION_FILE"; then
return
fi
GETTOGETHER_DOMAIN_NAME=$(get_completion_param "gettogether domain")
if [ ! "$GETTOGETHER_DOMAIN_NAME" ]; then
return
fi
suspend_site "${GETTOGETHER_DOMAIN_NAME}"
systemctl stop gettogether
temp_restore_dir=/root/tempgettogether
gettogether_dir=/etc/gettogether
restore_directory_from_usb $temp_restore_dir gettogether
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir$gettogether_dir" ]; then
cp -rp "$temp_restore_dir$gettogether_dir"/* "$gettogether_dir"/
else
if [ ! -d "$gettogether_dir" ]; then
mkdir "$gettogether_dir"
fi
cp -rp "$temp_restore_dir"/* "$gettogether_dir"/
fi
chown -R gettogether:gettogether "$gettogether_dir"
rm -rf $temp_restore_dir
fi
systemctl start gettogether
restart_site
}
function backup_remote_gettogether {
GETTOGETHER_DOMAIN_NAME='gettogether'
if grep -q "gettogether domain" "$COMPLETION_FILE"; then
GETTOGETHER_DOMAIN_NAME=$(get_completion_param "gettogether domain")
fi
source_directory=/etc/gettogether
suspend_site "${GETTOGETHER_DOMAIN_NAME}"
systemctl stop gettogether
dest_directory=gettogether
backup_directory_to_friend "$source_directory" $dest_directory
systemctl start gettogether
restart_site
}
function restore_remote_gettogether {
if ! grep -q "gettogether domain" "$COMPLETION_FILE"; then
return
fi
GETTOGETHER_DOMAIN_NAME=$(get_completion_param "gettogether domain")
if [ ! "$GETTOGETHER_DOMAIN_NAME" ]; then
return
fi
suspend_site "${GETTOGETHER_DOMAIN_NAME}"
systemctl stop gettogether
temp_restore_dir=/root/tempgettogether
gettogether_dir=/etc/gettogether
restore_directory_from_friend $temp_restore_dir gettogether
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir$gettogether_dir" ]; then
cp -rp "$temp_restore_dir$gettogether_dir"/* "$gettogether_dir"/
else
if [ ! -d "$gettogether_dir" ]; then
mkdir "$gettogether_dir"
fi
cp -rp $temp_restore_dir/* "$gettogether_dir"/
fi
chown -R gettogether:gettogether "$gettogether_dir"
rm -rf $temp_restore_dir
fi
systemctl start gettogether
restart_site
}
function remove_gettogether {
nginx_dissite "$GETTOGETHER_DOMAIN_NAME"
remove_certs "$GETTOGETHER_DOMAIN_NAME"
if [ -f /etc/systemd/system/gettogether.service ]; then
systemctl stop gettogether
systemctl disable gettogether
rm /etc/systemd/system/gettogether.service
fi
userdel -r gettogether
if [ -d "/var/www/$GETTOGETHER_DOMAIN_NAME" ]; then
rm -rf "/var/www/$GETTOGETHER_DOMAIN_NAME"
fi
if [ -f "/etc/nginx/sites-available/$GETTOGETHER_DOMAIN_NAME" ]; then
rm "/etc/nginx/sites-available/$GETTOGETHER_DOMAIN_NAME"
fi
remove_onion_service gettogether "${GETTOGETHER_ONION_PORT}"
if grep -q "gettogether" /etc/crontab; then
sed -i "/gettogether/d" /etc/crontab
fi
remove_app gettogether
remove_completion_param install_gettogether
sed -i '/gettogether/d' "$COMPLETION_FILE"
remove_ddns_domain "$GETTOGETHER_DOMAIN_NAME"
}
function install_gettogether {
if [ ! "$GETTOGETHER_DOMAIN_NAME" ]; then
echo $'No domain name was given'
exit 3568356
fi
$INSTALL_PACKAGES python3 python3-pip python3-virtualenv
if [ -d "/var/www/$GETTOGETHER_DOMAIN_NAME/htdocs" ]; then
rm -rf "/var/www/$GETTOGETHER_DOMAIN_NAME/htdocs"
fi
if [ -d /repos/gettogether ]; then
mkdir "/var/www/$GETTOGETHER_DOMAIN_NAME/htdocs"
cp -r -p /repos/gettogether/. "/etc/gettogether"
cd "/etc/gettogether" || exit 36487365
git pull
else
git_clone "$GETTOGETHER_REPO" "/etc/gettogether"
fi
if [ ! -d "/etc/gettogether" ]; then
echo $'Unable to clone gettogether repo'
exit 87525
fi
cd "/etc/gettogether" || exit 3463754637
git checkout "$GETTOGETHER_COMMIT" -b "$GETTOGETHER_COMMIT"
set_completion_param "gettogether commit" "$GETTOGETHER_COMMIT"
virtualenv --python=python3 ./env
if [ ! -d env ]; then
exit 67843643234
fi
./env/bin/pip install -r requirements.txt
./env/bin/python manage.py migrate
./env/bin/python manage.py createsuperuser
if [ -f /root/freedombone/image_build/countryinfo.txt ]; then
./env/bin/python manage.py load_countries /root/freedombone/image_build/countryinfo.txt
else
if [ -f "/home/$MY_USERNAME/freedombone/image_build/countryinfo.txt" ]; then
./env/bin/python manage.py load_countries "/home/$MY_USERNAME/freedombone/image_build/countryinfo.txt"
else
echo $'countryinfo.txt not found'
exit 678348
fi
fi
if [ -f /root/freedombone/image_build/codesascii.txt ]; then
./env/bin/python manage.py load_spr /root/freedombone/image_build/codesascii.txt
else
if [ -f "/home/$MY_USERNAME/freedombone/image_build/codesascii.txt" ]; then
./env/bin/python manage.py load_spr "/home/$MY_USERNAME/freedombone/image_build/codesascii.txt"
else
echo $'codesascii.txt not found'
exit 56802346
fi
fi
chmod g+w "/var/www/$GETTOGETHER_DOMAIN_NAME/htdocs"
chown -R www-data:www-data "/var/www/$GETTOGETHER_DOMAIN_NAME/htdocs"
add_ddns_domain "$GETTOGETHER_DOMAIN_NAME"
GETTOGETHER_ONION_HOSTNAME=$(add_onion_service gettogether 80 "${GETTOGETHER_ONION_PORT}")
gettogether_nginx_site=/etc/nginx/sites-available/$GETTOGETHER_DOMAIN_NAME
if [[ "$ONION_ONLY" == "no" ]]; then
nginx_http_redirect "$GETTOGETHER_DOMAIN_NAME" "index index.html"
{ echo 'server {';
echo ' listen 443 ssl;';
echo ' #listen [::]:443 ssl;';
echo " server_name $GETTOGETHER_DOMAIN_NAME;";
echo ''; } >> "$gettogether_nginx_site"
nginx_compress "$GETTOGETHER_DOMAIN_NAME"
echo '' >> "$gettogether_nginx_site"
echo ' # Security' >> "$gettogether_nginx_site"
nginx_ssl "$GETTOGETHER_DOMAIN_NAME"
nginx_security_options "$GETTOGETHER_DOMAIN_NAME"
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
echo '';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo " root /var/www/$GETTOGETHER_DOMAIN_NAME/htdocs;";
echo '';
echo ' index index.html;';
echo ' # Location';
echo ' location / {'; } >> "$gettogether_nginx_site"
nginx_limits "$GETTOGETHER_DOMAIN_NAME" '15m'
{ echo " proxy_pass http://localhost:$GETTOGETHER_PORT_INTERNAL;";
echo ' }';
echo '}'; } >> "$gettogether_nginx_site"
else
echo -n '' > "$gettogether_nginx_site"
fi
{ echo 'server {';
echo " listen 127.0.0.1:$GETTOGETHER_ONION_PORT default_server;";
echo " server_name $GETTOGETHER_ONION_HOSTNAME;";
echo ''; } >> "$gettogether_nginx_site"
nginx_compress "$GETTOGETHER_DOMAIN_NAME"
echo '' >> "$gettogether_nginx_site"
nginx_security_options "$GETTOGETHER_DOMAIN_NAME"
{ echo '';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo " root /var/www/$GETTOGETHER_DOMAIN_NAME/htdocs;";
echo '';
echo ' index index.html;';
echo ' # Location';
echo ' location / {'; } >> "$gettogether_nginx_site"
nginx_limits "$GETTOGETHER_DOMAIN_NAME" '15m'
{ echo " proxy_pass http://localhost:$GETTOGETHER_PORT_INTERNAL;";
echo ' }';
echo '}'; } >> "$gettogether_nginx_site"
adduser --system --home="/etc/gettogether" --group gettogether
{ echo '[Unit]';
echo 'Description=gettogether';
echo 'After=syslog.target';
echo 'After=network.target';
echo "Documentation=$GETTOGETHER_REPO";
echo '';
echo '[Service]';
echo 'Type=simple';
echo 'User=gettogether';
echo 'Group=gettogether';
echo 'WorkingDirectory=/etc/gettogether';
echo "ExecStart=/etc/gettogether/env/bin/python manage.py runserver 127.0.0.1:$GETTOGETHER_PORT_INTERNAL";
echo 'Environment=USER=gettogether';
echo 'Restart=always';
echo 'StandardError=syslog';
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } > "/etc/systemd/system/gettogether.service"
systemctl enable gettogether
chown -R gettogether:gettogether "/etc/gettogether"
systemctl start gettogether
create_site_certificate "$GETTOGETHER_DOMAIN_NAME" 'yes'
nginx_ensite "$GETTOGETHER_DOMAIN_NAME"
systemctl restart nginx
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a gettogether -p "$GETTOGETHER_ADMIN_PASSWORD"
set_completion_param "gettogether domain" "$GETTOGETHER_DOMAIN_NAME"
APP_INSTALLED=1
}
# NOTE: deliberately there is no "exit 0"
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