Browse Source

Loading of app variables

stockholm
Bob Mottram 5 years ago
parent
commit
3ab2687019
  1. 1
      src/freedombone-adduser
  2. 2
      src/freedombone-app-babel
  3. 3
      src/freedombone-app-batman
  4. 46
      src/freedombone-app-blog
  5. 3
      src/freedombone-app-blogstatic
  6. 10
      src/freedombone-app-cjdns
  7. 5
      src/freedombone-app-dlna
  8. 3
      src/freedombone-app-emacs
  9. 31
      src/freedombone-app-gnusocial
  10. 543
      src/freedombone-app-gogs
  11. 158
      src/freedombone-app-hubzilla
  12. 5
      src/freedombone-app-ipfs
  13. 343
      src/freedombone-app-irc
  14. 6
      src/freedombone-app-librevault
  15. 96
      src/freedombone-app-mediagoblin
  16. 6
      src/freedombone-app-mumble
  17. 143
      src/freedombone-app-rss
  18. 7
      src/freedombone-app-searx
  19. 13
      src/freedombone-app-sip
  20. 10
      src/freedombone-app-syncthing
  21. 6
      src/freedombone-app-tahoelafs
  22. 10
      src/freedombone-app-tox
  23. 2
      src/freedombone-app-vpn
  24. 6
      src/freedombone-app-webmail
  25. 45
      src/freedombone-app-wiki
  26. 8
      src/freedombone-app-xmpp
  27. 10
      src/freedombone-app-zeronet
  28. 1
      src/freedombone-rmuser
  29. 2
      src/freedombone-utils-backup
  30. 100
      src/freedombone-utils-config
  31. 35
      src/freedombone-utils-selector

1
src/freedombone-adduser

@ -216,6 +216,7 @@ for app_name in "${APPS_INSTALLED_NAMES[@]}"
do
if [[ $(function_exists add_user_${app_name}) == "1" ]]; then
echo $"Adding user to ${app_name}"
app_load_variables ${app_name}
retval=$(add_user_${app_name} "$MY_USERNAME" "$NEW_USER_PASSWORD")
if [[ $retval != '0' ]]; then
echo $"Failed with error code ${retval}"

2
src/freedombone-app-babel

@ -33,6 +33,8 @@ VARIANTS=''
ENABLE_BABEL="no"
BABEL_PORT=6696
babel_variables=()
function install_interactive_babel {
echo -n ''
}

3
src/freedombone-app-batman

@ -33,6 +33,9 @@ VARIANTS=''
ENABLE_BATMAN="no"
BATMAN_CELLID='any'
batman_variables=(MY_USERNAME
BATMAN_CELLID)
function install_interactive_batman {
echo -n ''
}

46
src/freedombone-app-blog

@ -38,10 +38,19 @@ FULLBLOG_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
MY_BLOG_TITLE="My Blog"
MY_BLOG_SUBTITLE="Another ${PROJECT_NAME} Blog"
blog_variables=(FULLBLOG_REPO
FULLBLOG_COMMIT
FULLBLOG_DOMAIN_NAME
FULLBLOG_CODE
MY_BLOG_TITLE
MY_BLOG_SUBTITLE
ONION_ONLY
DDNS_PROVIDER
MY_USERNAME)
function remove_user_blog {
remove_username="$1"
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | head -n 1 | awk -F ':' '{print $2}')
if [ -f /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
rm /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
fi
@ -56,7 +65,6 @@ function add_user_blog {
new_username="$1"
new_user_password="$2"
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | head -n 1 | awk -F ':' '{print $2}')
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users ]; then
echo '2'
return
@ -100,21 +108,6 @@ function install_interactive_blog {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "MY_BLOG_TITLE" $CONFIGURATION_FILE; then
MY_BLOG_TITLE=$(grep "MY_BLOG_TITLE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then
FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "FULLBLOG_CODE" $CONFIGURATION_FILE; then
FULLBLOG_CODE=$(grep "FULLBLOG_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [[ $ONION_ONLY != "no" ]]; then
MY_BLOG_TITLE='My Blog'
@ -351,6 +344,7 @@ function remove_blog {
if [[ $(app_is_installed blog) == "0" ]]; then
return
fi
if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then
FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
@ -630,24 +624,6 @@ function install_blog {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then
FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "FULLBLOG_CODE" $CONFIGURATION_FILE; then
FULLBLOG_CODE=$(grep "FULLBLOG_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "MY_BLOG_TITLE" $CONFIGURATION_FILE; then
MY_BLOG_TITLE=$(grep "MY_BLOG_TITLE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then
MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [ ! $FULLBLOG_DOMAIN_NAME ]; then
echo $'The blog domain name was not specified'

3
src/freedombone-app-blogstatic

@ -35,6 +35,9 @@ PELICAN_THEMES_REPO="https://github.com/getpelican/pelican-themes"
PELICAN_PLUGINS_REPO="https://github.com/getpelican/pelican-plugins"
DEFAULT_BLOG_TITLE=$"Freedombone Blog"
blogstatic_variables=(MY_USERNAME
STATIC_BLOG_DOMAIN)
function configure_interactive_blogstatic {
echo -n ''
}

10
src/freedombone-app-cjdns

@ -41,6 +41,16 @@ CJDNS_COMMIT='13189fde111d0500427a7a0ce06a970753527bca'
CJDCMD_REPO="https://github.com/inhies/cjdcmd"
CJDCMD_COMMIT='973cca6ed0eecf9041c3403a40193c0b1291b808'
cjdns_variables=(MY_USERNAME
CJDNS_PORT
CJDNS_REPO
CJDNS_COMMIT
CJDCMD_REPO
CJDCMD_COMMIT
CJDNS_IPV6
CJDNS_PUBLIC_KEY
CJDNS_PRIVATE_KEY)
function install_interactive_cjdns {
echo -n ''
}

5
src/freedombone-app-dlna

@ -30,6 +30,11 @@
VARIANTS='full media'
dlna_variables=(SYSTEM_TYPE
USB_MOUNT
INSTALLED_WITHIN_DOCKER
MY_USERNAME)
function configure_interactive_dlna {
while true
do

3
src/freedombone-app-emacs

@ -30,6 +30,9 @@
VARIANTS='all'
emacs_variables=(USB_MOUNT
MY_USERNAME)
function install_interactive_emacs {
echo -n ''
}

31
src/freedombone-app-gnusocial

@ -56,6 +56,21 @@ GNUSOCIAL_NSFW_COMMIT='a096bbe0cfae9a9b177682920ffb58d32a48e136'
# script which causes old posts to expire
gnusocial_expire_script=/usr/bin/gnusocial-expire
gnusocial_variables=(MICROBLOG_COMMIT
ONION_ONLY
MICROBLOG_DOMAIN_NAME
MICROBLOG_CODE
MICROBLOG_WELCOME_MESSAGE
MICROBLOG_BACKGROUND_IMAGE_URL
DDNS_PROVIDER
MICROBLOG_MARKDOWN_REPO
MICROBLOG_MARKDOWN_COMMIT
SHARINGS_REPO
SHARINGS_COMMIT
SHARINGS_THEME_REPO
SHARINGS_THEME_COMMIT
MY_USERNAME)
function remove_user_gnusocial {
remove_username="$1"
@ -86,14 +101,6 @@ function install_interactive_gnusocial {
ONION_ONLY='no'
fi
read_config_param "MICROBLOG_COMMIT"
read_config_param "ONION_ONLY"
read_config_param "MICROBLOG_DOMAIN_NAME"
read_config_param "MICROBLOG_CODE"
read_config_param "MICROBLOG_WELCOME_MESSAGE"
read_config_param "MICROBLOG_BACKGROUND_IMAGE_URL"
read_config_param "DDNS_PROVIDER"
if [[ $ONION_ONLY != "no" ]]; then
MICROBLOG_DOMAIN_NAME='microblog.local'
else
@ -241,7 +248,6 @@ function upgrade_gnusocial {
if grep -q "gnusocial domain" $COMPLETION_FILE; then
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
fi
read_config_param "MICROBLOG_COMMIT"
# update to the next commit
function_check set_repo_commit
@ -1031,13 +1037,6 @@ function install_gnusocial {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
read_config_param "MICROBLOG_COMMIT"
read_config_param "ONION_ONLY"
read_config_param "MICROBLOG_DOMAIN_NAME"
read_config_param "MICROBLOG_CODE"
read_config_param "MICROBLOG_WELCOME_MESSAGE"
read_config_param "MICROBLOG_BACKGROUND_IMAGE_URL"
read_config_param "DDNS_PROVIDER"
install_gnusocial_main
expire_gnusocial_posts

543
src/freedombone-app-gogs

@ -39,22 +39,18 @@ GIT_ONION_PORT=8090
GIT_ADMIN_PASSWORD=
GOGS_BIN=
gogs_variables=(ONION_ONLY
GOGS_COMMIT
GIT_ADMIN_PASSWORD
GIT_DOMAIN_NAME
GIT_CODE
GIT_ONION_PORT
MY_USERNAME
GOGS_VERSION
DDNS_PROVIDER
ARCHITECTURE)
function install_interactive_gogs {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "GIT_DOMAIN_NAME" $CONFIGURATION_FILE; then
GIT_DOMAIN_NAME=$(grep "GIT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "GIT_CODE" $CONFIGURATION_FILE; then
GIT_CODE=$(grep "GIT_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [[ $ONION_ONLY != "no" ]]; then
GIT_DOMAIN_NAME='git.local'
else
@ -84,17 +80,17 @@ function install_interactive_gogs {
255) exit 1;;
esac
GIT_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $GIT_DOMAIN_NAME ]; then
if [ ${GIT_DOMAIN_NAME} ]; then
TEST_DOMAIN_NAME=$GIT_DOMAIN_NAME
validate_domain_name
if [[ $TEST_DOMAIN_NAME != $GIT_DOMAIN_NAME ]]; then
if [[ ${TEST_DOMAIN_NAME} != ${GIT_DOMAIN_NAME} ]]; then
GIT_DOMAIN_NAME=
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
dialog --title $"Domain name validation" --msgbox "${TEST_DOMAIN_NAME}" 15 50
else
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
if [[ ${DDNS_PROVIDER} == "default@freedns.afraid.org" ]]; then
GIT_CODE=$(cat $data | sed -n 2p)
validate_freedns_code "$GIT_CODE"
if [ ! $VALID_CODE ]; then
if [ ! ${VALID_CODE} ]; then
GIT_DOMAIN_NAME=
fi
fi
@ -102,21 +98,21 @@ function install_interactive_gogs {
else
DEVELOPER_DETAILS_COMPLETE="yes"
fi
if [ $GIT_DOMAIN_NAME ]; then
if [ ${GIT_DOMAIN_NAME} ]; then
DEVELOPER_DETAILS_COMPLETE="yes"
fi
done
# save the results in the config file
if grep -q "GIT_DOMAIN_NAME=" $CONFIGURATION_FILE; then
sed -i "s|GIT_DOMAIN_NAME=.*|GIT_DOMAIN_NAME=$GIT_DOMAIN_NAME|g" $CONFIGURATION_FILE
if grep -q "GIT_DOMAIN_NAME=" ${CONFIGURATION_FILE}; then
sed -i "s|GIT_DOMAIN_NAME=.*|GIT_DOMAIN_NAME=$GIT_DOMAIN_NAME|g" ${CONFIGURATION_FILE}
else
echo "GIT_DOMAIN_NAME=$GIT_DOMAIN_NAME" >> $CONFIGURATION_FILE
echo "GIT_DOMAIN_NAME=$GIT_DOMAIN_NAME" >> ${CONFIGURATION_FILE}
fi
if grep -q "GIT_CODE=" $CONFIGURATION_FILE; then
sed -i "s|GIT_CODE=.*|GIT_CODE=$GIT_CODE|g" $CONFIGURATION_FILE
if grep -q "GIT_CODE=" ${CONFIGURATION_FILE}; then
sed -i "s|GIT_CODE=.*|GIT_CODE=$GIT_CODE|g" ${CONFIGURATION_FILE}
else
echo "GIT_CODE=$GIT_CODE" >> $CONFIGURATION_FILE
echo "GIT_CODE=$GIT_CODE" >> ${CONFIGURATION_FILE}
fi
fi
}
@ -126,25 +122,25 @@ function change_password_gogs {
}
function gogs_parameters {
if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then
CURR_ARCH=386
fi
if [[ $ARCHITECTURE == *"amd64" || $ARCHITECTURE == "x86_64" ]]; then
if [[ ${ARCHITECTURE} == *"amd64" || ${ARCHITECTURE} == "x86_64" ]]; then
CURR_ARCH=amd64
fi
if [[ $ARCHITECTURE == *"arm"* ]]; then
if [[ ${ARCHITECTURE} == *"arm"* ]]; then
CURR_ARCH=arm
fi
if [ ! $CURR_ARCH ]; then
if [ ! ${CURR_ARCH} ]; then
echo $'No architecture specified'
ARCHITECTURE=$(uname -m)
if [[ $ARCHITECTURE == "arm"* ]]; then
if [[ ${ARCHITECTURE} == "arm"* ]]; then
CURR_ARCH=arm
fi
if [[ $ARCHITECTURE == "amd"* || $ARCHITECTURE == "x86_64" ]]; then
if [[ ${ARCHITECTURE} == "amd"* || ${ARCHITECTURE} == "x86_64" ]]; then
CURR_ARCH=amd64
fi
if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then
CURR_ARCH=386
fi
fi
@ -153,9 +149,9 @@ function gogs_parameters {
}
function get_mariadb_git_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "Gogs admin user password" /home/$MY_USERNAME/README; then
GIT_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Gogs admin user password" | awk -F ':' '{print $2}' | sed 's/^ *//')
if [ -f /home/${MY_USERNAME}/README ]; then
if grep -q "Gogs admin user password" /home/${MY_USERNAME}/README; then
GIT_ADMIN_PASSWORD=$(cat /home/${MY_USERNAME}/README | grep "Gogs admin user password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
@ -163,8 +159,9 @@ function get_mariadb_git_admin_password {
function gogs_create_database {
function_check get_mariadb_git_admin_password
get_mariadb_git_admin_password
if [ ! $GIT_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
if [ ! ${GIT_ADMIN_PASSWORD} ]; then
if [ -f ${IMAGE_PASSWORD_FILE} ]; then
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
GIT_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
@ -188,7 +185,7 @@ function upgrade_gogs {
fi
CURR_GOGS_VERSION=$(cat $COMPLETION_FILE | grep "gogs version" | head -n 1 | awk -F ':' '{print $2}')
if [[ "$CURR_GOGS_VERSION" == "$GOGS_VERSION" ]]; then
if [[ "${CURR_GOGS_VERSION}" == "${GOGS_VERSION}" ]]; then
return
fi
@ -198,14 +195,14 @@ function upgrade_gogs {
mkdir -p ${INSTALL_DIR}
fi
cd ${INSTALL_DIR}
if [ -d $INSTALL_DIR/gogs ]; then
rm -rf $INSTALL_DIR/gogs
if [ -d ${INSTALL_DIR}/gogs ]; then
rm -rf ${INSTALL_DIR}/gogs
fi
GOGS_FILE=linux_${CURR_ARCH}.tar.gz
if [ ! -f $GOGS_FILE ]; then
if [ ! -f ${GOGS_FILE} ]; then
wget ${GOGS_BIN}
fi
if [ ! -f $GOGS_FILE ]; then
if [ ! -f ${GOGS_FILE} ]; then
GOGS_FILE=linux_${CURR_ARCH}.zip
GOGS_BIN="https://github.com/gogits/gogs/releases/download/v${GOGS_VERSION}/${GOGS_FILE}"
if [ ! -f ${GOGS_FILE} ]; then
@ -220,53 +217,49 @@ function upgrade_gogs {
else
tar -xzf ${INSTALL_DIR}/${GOGS_FILE}
fi
if [ ! -d $INSTALL_DIR/gogs ]; then
if [ ! -d ${INSTALL_DIR}/gogs ]; then
exit 37823
fi
rm -rf /home/$GOGS_USERNAME/*
cp -r $INSTALL_DIR/gogs/* /home/$GOGS_USERNAME
rm -rf /home/${GOGS_USERNAME}/*
cp -r ${INSTALL_DIR}/gogs/* /home/${GOGS_USERNAME}
if [ -f ${GOGS_FILE} ]; then
rm ${GOGS_FILE}
fi
sed -i "s|gogs version.*|gogs version:$GOGS_VERSION|g" $COMPLETION_FILE
sed -i "s|gogs version.*|gogs version:$GOGS_VERSION|g" ${COMPLETION_FILE}
systemctl restart gogs
}
function backup_local_gogs {
if ! grep -q "gogs domain" $COMPLETION_FILE; then
if ! grep -q "gogs domain" ${COMPLETION_FILE}; then
return
fi
if [ ! -d /home/$GOGS_USERNAME/gogs-repositories ]; then
if [ ! -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
return
fi
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gogs domain" | awk -F ':' '{print $2}')
echo $"Backing up gogs"
function_check backup_database_to_usb
backup_database_to_usb gogs
function_check backup_directory_to_usb
backup_directory_to_usb /home/$GOGS_USERNAME/custom gogs
backup_directory_to_usb /home/$GOGS_USERNAME/gogs-repositories gogsrepos
backup_directory_to_usb /home/$GOGS_USERNAME/.ssh gogsssh
backup_directory_to_usb /home/${GOGS_USERNAME}/custom gogs
backup_directory_to_usb /home/${GOGS_USERNAME}/gogs-repositories gogsrepos
backup_directory_to_usb /home/${GOGS_USERNAME}/.ssh gogsssh
echo $"Gogs backup complete"
}
function restore_local_gogs {
if ! grep -q "gogs domain" $COMPLETION_FILE; then
if ! grep -q "gogs domain" ${COMPLETION_FILE}; then
return
fi
if [ ! -d /home/$GOGS_USERNAME/gogs-repositories ]; then
if [ ! -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
return
fi
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gogs domain" | awk -F ':' '{print $2}')
if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then
function_check gogs_create_database
gogs_create_database
@ -274,12 +267,12 @@ function restore_local_gogs {
function_check restore_database
restore_database gogs ${GIT_DOMAIN_NAME}
temp_restore_dir=/root/tempgogs
if [ -d $USB_MOUNT/backup/gogs ]; then
if [ -d ${USB_MOUNT}/backup/gogs ]; then
echo $"Restoring Gogs settings"
if [ ! -d /home/$GOGS_USERNAME/custom ]; then
mkdir -p /home/$GOGS_USERNAME/custom
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom
fi
cp -r ${temp_restore_dir}/home/$GOGS_USERNAME/custom/* /home/$GOGS_USERNAME/custom
cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -290,7 +283,7 @@ function restore_local_gogs {
echo $"Restoring Gogs repos"
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
cp -r ${temp_restore_dir}repos/home/$GOGS_USERNAME/gogs-repositories/* /home/$GOGS_USERNAME/gogs-repositories/
cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -301,10 +294,10 @@ function restore_local_gogs {
echo $"Restoring Gogs authorized_keys"
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}ssh gogsssh
if [ ! -d /home/$GOGS_USERNAME/.ssh ]; then
mkdir /home/$GOGS_USERNAME/.ssh
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh
fi
cp -r ${temp_restore_dir}ssh/home/$GOGS_USERNAME/.ssh/* /home/$GOGS_USERNAME/.ssh/
cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
if [ ! "$?" = "0" ]; then
function_check set_user_permissions
set_user_permissions
@ -315,14 +308,13 @@ function restore_local_gogs {
rm -rf ${temp_restore_dir}
rm -rf ${temp_restore_dir}repos
rm -rf ${temp_restore_dir}ssh
chown -R $GOGS_USERNAME:$GOGS_USERNAME /home/$GOGS_USERNAME
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
fi
fi
}
function backup_remote_gogs {
if [ -d /home/$GOGS_USERNAME ]; then
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gogs domain" | awk -F ':' '{print $2}')
function_check suspend_site
suspend_site ${GIT_DOMAIN_NAME}
@ -358,34 +350,34 @@ function restore_remote_gogs {
gogs_create_database
function_check restore_database_from_friend
restore_database_from_friend gogs $GIT_DOMAIN_NAME
if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
if [ ! -d /home/$GOGS_USERNAME/custom ]; then
mkdir -p /home/$GOGS_USERNAME/custom
restore_database_from_friend gogs ${GIT_DOMAIN_NAME}
if [ -d ${SERVER_DIRECTORY}/backup/gogs ]; then
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom
fi
cp -r /root/tempgogs/home/$GOGS_USERNAME/custom/* /home/$GOGS_USERNAME/custom/
cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
if [ ! "$?" = "0" ]; then
exit 58852
fi
echo $"Restoring Gogs repos"
restore_directory_from_friend /root/tempgogsrepos gogsrepos
cp -r /root/tempgogsrepos/home/$GOGS_USERNAME/gogs-repositories/* /home/$GOGS_USERNAME/gogs-repositories/
cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
if [ ! "$?" = "0" ]; then
exit 7649
fi
echo $"Restoring Gogs authorized_keys"
restore_directory_from_friend /root/tempgogsssh gogsssh
if [ ! -d /home/$GOGS_USERNAME/.ssh ]; then
mkdir /home/$GOGS_USERNAME/.ssh
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh
fi
cp -r /root/tempgogsssh/home/$GOGS_USERNAME/.ssh/* /home/$GOGS_USERNAME/.ssh/
cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
if [ ! "$?" = "0" ]; then
exit 74239
fi
rm -rf /root/tempgogs
rm -rf /root/tempgogsrepos
rm -rf /root/tempgogsssh
chown -R $GOGS_USERNAME:$GOGS_USERNAME /home/$GOGS_USERNAME
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
echo $"Restore of Gogs complete"
fi
fi
@ -396,44 +388,25 @@ function remove_gogs {
return
fi
if grep -q "GIT_DOMAIN_NAME" $CONFIGURATION_FILE; then
GIT_DOMAIN_NAME=$(grep "GIT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
systemctl stop gogs
systemctl disable gogs
nginx_dissite $GIT_DOMAIN_NAME
if [ -d /var/www/$GIT_DOMAIN_NAME ]; then
rm -rf /var/www/$GIT_DOMAIN_NAME
nginx_dissite ${GIT_DOMAIN_NAME}
if [ -d /var/www/${GIT_DOMAIN_NAME} ]; then
rm -rf /var/www/${GIT_DOMAIN_NAME}
fi
if [ -f /etc/nginx/sites-available/$GIT_DOMAIN_NAME ]; then
rm /etc/nginx/sites-available/$GIT_DOMAIN_NAME
if [ -f /etc/nginx/sites-available/${GIT_DOMAIN_NAME} ]; then
rm /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
fi
function_check drop_database
drop_database gogs
rm /etc/systemd/system/gogs.service
rm -rf /home/$GOGS_USERNAME/*
rm -rf /home/${GOGS_USERNAME}/*
remove_onion_service gogs ${GIT_ONION_PORT} 9418
sed -i '/install_gogs/d' $COMPLETION_FILE
sed -i '/Gogs /d' $COMPLETION_FILE
sed -i '/gogs /d' $COMPLETION_FILE
}
function install_gogs {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "GIT_DOMAIN_NAME" $CONFIGURATION_FILE; then
GIT_DOMAIN_NAME=$(grep "GIT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "GIT_CODE" $CONFIGURATION_FILE; then
GIT_CODE=$(grep "GIT_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [ ! $GIT_DOMAIN_NAME ]; then
return
fi
@ -466,24 +439,24 @@ function install_gogs {
else
tar -xzf ${INSTALL_DIR}/${GOGS_FILE}
fi
if [ ! -d $INSTALL_DIR/gogs ]; then
if [ ! -d ${INSTALL_DIR}/gogs ]; then
exit 37823
fi
rm -rf /home/$GOGS_USERNAME/*
cp -r $INSTALL_DIR/gogs/* /home/$GOGS_USERNAME
rm -rf /home/${GOGS_USERNAME}/*
cp -r ${INSTALL_DIR}/gogs/* /home/${GOGS_USERNAME}
if [ -f ${GOGS_FILE} ]; then
rm ${GOGS_FILE}
fi
if [ ! -f /home/$GOGS_USERNAME/gogs ]; then
if [ ! -f /home/${GOGS_USERNAME}/gogs ]; then
echo 'Gogs binary not installed'
exit 345562
fi
echo "export GOROOT=/home/go" >> /home/$GOGS_USERNAME/.bashrc
echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> /home/$GOGS_USERNAME/.bashrc
echo 'export PATH=$PATH:$GOPATH' >> /home/$GOGS_USERNAME/.bashrc
chown -R $GOGS_USERNAME:$GOGS_USERNAME /home/$GOGS_USERNAME
echo "export GOROOT=/home/go" >> /home/${GOGS_USERNAME}/.bashrc
echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> /home/${GOGS_USERNAME}/.bashrc
echo 'export PATH=$PATH:$GOPATH' >> /home/${GOGS_USERNAME}/.bashrc
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
function_check install_mariadb
install_mariadb
@ -494,44 +467,44 @@ function install_gogs {
function_check gogs_create_database
gogs_create_database
if [ ! -f /home/$GOGS_USERNAME/scripts/mysql.sql ]; then
if [ ! -f /home/${GOGS_USERNAME}/scripts/mysql.sql ]; then
echo $'MySql template for Gogs was not found'
exit 72528
fi
if ! grep -q $"Gogs admin user password" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo 'Gogs' >> /home/$MY_USERNAME/README
echo '====' >> /home/$MY_USERNAME/README
echo $'Install Steps For First-time Run:' >> /home/$MY_USERNAME/README
echo $'Leave email service settings empty' >> /home/$MY_USERNAME/README
echo $'Check "Enable Register Confirmation"' >> /home/$MY_USERNAME/README
echo $'Check "Enable Mail Notification"' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo $'If you want to disable new account registrations then append the following:' >> /home/$MY_USERNAME/README
echo ' [service]' >> /home/$MY_USERNAME/README
echo ' DISABLE_REGISTRATION = true' >> /home/$MY_USERNAME/README
echo $'Then restart with:' >> /home/$MY_USERNAME/README
echo ' systemctl restart gogs' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo $"Note that there's a usability/security trade-off made here." >> /home/$MY_USERNAME/README
echo $"In order to allow git clone via http we don't redirect everything" >> /home/$MY_USERNAME/README
echo $'over https. Instead only critical things such as user login,' >> /home/$MY_USERNAME/README
echo $'settings and admin are encrypted.' >> /home/$MY_USERNAME/README
echo $'There are also potential security issues with cloning/pulling/pushing' >> /home/$MY_USERNAME/README
echo $'code over http, since a determined adversary could inject malware' >> /home/$MY_USERNAME/README
echo $'into the stream as it passes, so beware.' >> /home/$MY_USERNAME/README
echo $'If you have a bought domain and a non-self signed cert then you' >> /home/$MY_USERNAME/README
echo $"should change /etc/nginx/sites-available/$GIT_DOMAIN_NAME to redirect everything over https." >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
if ! grep -q $"Gogs admin user password" /home/${MY_USERNAME}/README; then
echo '' >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
echo 'Gogs' >> /home/${MY_USERNAME}/README
echo '====' >> /home/${MY_USERNAME}/README
echo $'Install Steps For First-time Run:' >> /home/${MY_USERNAME}/README
echo $'Leave email service settings empty' >> /home/${MY_USERNAME}/README
echo $'Check "Enable Register Confirmation"' >> /home/${MY_USERNAME}/README
echo $'Check "Enable Mail Notification"' >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
echo $'If you want to disable new account registrations then append the following:' >> /home/${MY_USERNAME}/README
echo ' [service]' >> /home/${MY_USERNAME}/README
echo ' DISABLE_REGISTRATION = true' >> /home/${MY_USERNAME}/README
echo $'Then restart with:' >> /home/${MY_USERNAME}/README
echo ' systemctl restart gogs' >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
echo $"Note that there's a usability/security trade-off made here." >> /home/${MY_USERNAME}/README
echo $"In order to allow git clone via http we don't redirect everything" >> /home/${MY_USERNAME}/README
echo $'over https. Instead only critical things such as user login,' >> /home/${MY_USERNAME}/README
echo $'settings and admin are encrypted.' >> /home/${MY_USERNAME}/README
echo $'There are also potential security issues with cloning/pulling/pushing' >> /home/${MY_USERNAME}/README
echo $'code over http, since a determined adversary could inject malware' >> /home/${MY_USERNAME}/README
echo $'into the stream as it passes, so beware.' >> /home/${MY_USERNAME}/README
echo $'If you have a bought domain and a non-self signed cert then you' >> /home/${MY_USERNAME}/README
echo $"should change /etc/nginx/sites-available/${GIT_DOMAIN_NAME} to redirect everything over https." >> /home/${MY_USERNAME}/README
chown ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/README
chmod 600 /home/${MY_USERNAME}/README
fi
function_check initialise_database
initialise_database gogs /home/$GOGS_USERNAME/scripts/mysql.sql
initialise_database gogs /home/${GOGS_USERNAME}/scripts/mysql.sql
chown -R $GOGS_USERNAME:$GOGS_USERNAME /home/$GOGS_USERNAME
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
echo '[Unit]' > /etc/systemd/system/gogs.service
echo 'Description=Gogs (Go Git Service)' >> /etc/systemd/system/gogs.service
@ -545,11 +518,11 @@ function install_gogs {
echo 'Type=simple' >> /etc/systemd/system/gogs.service
echo 'User=gogs' >> /etc/systemd/system/gogs.service
echo 'Group=gogs' >> /etc/systemd/system/gogs.service
echo "WorkingDirectory=/home/$GOGS_USERNAME" >> /etc/systemd/system/gogs.service
echo "ExecStart=/home/$GOGS_USERNAME/gogs web" >> /etc/systemd/system/gogs.service
echo "WorkingDirectory=/home/${GOGS_USERNAME}" >> /etc/systemd/system/gogs.service
echo "ExecStart=/home/${GOGS_USERNAME}/gogs web" >> /etc/systemd/system/gogs.service
echo 'Restart=always' >> /etc/systemd/system/gogs.service
echo 'RestartSec=10' >> /etc/systemd/system/gogs.service
echo "Environment=\"USER=$GOGS_USERNAME\" \"HOME=/home/$GOGS_USERNAME\" \"GOPATH=/home/go/go${GO_VERSION}\"" >> /etc/systemd/system/gogs.service
echo "Environment=\"USER=${GOGS_USERNAME}\" \"HOME=/home/${GOGS_USERNAME}\" \"GOPATH=/home/go/go${GO_VERSION}\"" >> /etc/systemd/system/gogs.service
echo '' >> /etc/systemd/system/gogs.service
echo '[Install]' >> /etc/systemd/system/gogs.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/gogs.service
@ -558,86 +531,86 @@ function install_gogs {
systemctl daemon-reload
systemctl start gogs
if [ ! -d /var/www/$GIT_DOMAIN_NAME ]; then
mkdir /var/www/$GIT_DOMAIN_NAME
if [ ! -d /var/www/${GIT_DOMAIN_NAME} ]; then
mkdir /var/www/${GIT_DOMAIN_NAME}
fi
if [ -d /var/www/$GIT_DOMAIN_NAME/htdocs ]; then
rm -rf /var/www/$GIT_DOMAIN_NAME/htdocs
if [ -d /var/www/${GIT_DOMAIN_NAME}/htdocs ]; then
rm -rf /var/www/${GIT_DOMAIN_NAME}/htdocs
fi
if [[ $ONION_ONLY == "no" ]]; then
if [[ ${ONION_ONLY} == "no" ]]; then
function_check nginx_http_redirect
nginx_http_redirect $GIT_DOMAIN_NAME
echo 'server {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " root /var/www/$GIT_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " error_log /var/log/nginx/${GIT_DOMAIN_NAME}_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
nginx_http_redirect ${GIT_DOMAIN_NAME}
echo 'server {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " root /var/www/${GIT_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " server_name ${GIT_DOMAIN_NAME};" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' access_log off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " error_log /var/log/nginx/${GIT_DOMAIN_NAME}_error.log ${WEBSERVER_LOG_LEVEL};" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
function_check nginx_ssl
nginx_ssl $GIT_DOMAIN_NAME
nginx_ssl ${GIT_DOMAIN_NAME}
function_check nginx_disable_sniffing
nginx_disable_sniffing $GIT_DOMAIN_NAME
echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' location / {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
nginx_disable_sniffing ${GIT_DOMAIN_NAME}
echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' location / {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
function_check nginx_limits
nginx_limits $GIT_DOMAIN_NAME '10G'
echo ' proxy_pass http://localhost:3000;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' location = /robots.txt {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' allow all;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' log_not_found off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '}' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
nginx_limits ${GIT_DOMAIN_NAME} '10G'
echo ' proxy_pass http://localhost:3000;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' }' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' allow all;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' log_not_found off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' access_log off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' }' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '}' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
else
echo -n '' > /etc/nginx/sites-available/$GIT_DOMAIN_NAME
fi
echo 'server {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " listen 127.0.0.1:${GIT_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " root /var/www/$GIT_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " error_log /var/log/nginx/${GIT_DOMAIN_NAME}_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo -n '' > /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
fi
echo 'server {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " listen 127.0.0.1:${GIT_ONION_PORT} default_server;" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " root /var/www/$GIT_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' access_log off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo " error_log /var/log/nginx/${GIT_DOMAIN_NAME}_error.log ${WEBSERVER_LOG_LEVEL};" >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
function_check nginx_disable_sniffing
nginx_disable_sniffing $GIT_DOMAIN_NAME
echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' location / {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
nginx_disable_sniffing ${GIT_DOMAIN_NAME}
echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' location / {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
function_check nginx_limits
nginx_limits $GIT_DOMAIN_NAME '10G'
echo ' proxy_pass http://localhost:3000;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' location = /robots.txt {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' allow all;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' log_not_found off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo '}' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
nginx_limits ${GIT_DOMAIN_NAME} '10G'
echo ' proxy_pass http://localhost:3000;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' }' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' allow all;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' log_not_found off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' access_log off;' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo ' }' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
echo '}' >> /etc/nginx/sites-available/${GIT_DOMAIN_NAME}
function_check configure_php
configure_php
function_check create_site_certificate
create_site_certificate $GIT_DOMAIN_NAME 'yes'
create_site_certificate ${GIT_DOMAIN_NAME} 'yes'
nginx_ensite $GIT_DOMAIN_NAME
nginx_ensite ${GIT_DOMAIN_NAME}
if [ ! -d /var/lib/tor ]; then
echo $'No Tor installation found. Gogs onion site cannot be configured.'
@ -660,105 +633,105 @@ function install_gogs {
systemctl restart php5-fpm
systemctl restart nginx
if ! grep -q "Gogs onion domain" /home/$MY_USERNAME/README; then
echo "Gogs onion domain: ${GIT_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
if ! grep -q "Gogs onion domain" /home/${MY_USERNAME}/README; then
echo "Gogs onion domain: ${GIT_ONION_HOSTNAME}" >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
chown ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/README
chmod 600 /home/${MY_USERNAME}/README
fi
if ! grep -q "gogs onion domain" $COMPLETION_FILE; then
echo "gogs onion domain:${GIT_ONION_HOSTNAME}" >> $COMPLETION_FILE
if ! grep -q "gogs onion domain" ${COMPLETION_FILE}; then
echo "gogs onion domain:${GIT_ONION_HOSTNAME}" >> ${COMPLETION_FILE}
else
sed -i "s|gogs onion domain.*|gogs onion domain:${GIT_ONION_HOSTNAME}|g" $COMPLETION_FILE
sed -i "s|gogs onion domain.*|gogs onion domain:${GIT_ONION_HOSTNAME}|g" ${COMPLETION_FILE}
fi
function_check add_ddns_domain
add_ddns_domain $GIT_DOMAIN_NAME
add_ddns_domain ${GIT_DOMAIN_NAME}
# obtain the secret key
GOGS_SECRET_KEY=
if grep -q "Gogs secret key:" /home/$MY_USERNAME/README; then
GOGS_SECRET_KEY=$(cat /home/$MY_USERNAME/README | grep "Gogs secret key:" | awk -F ':' '{print $2}' | sed 's/^ *//')
if grep -q "Gogs secret key:" /home/${MY_USERNAME}/README; then
GOGS_SECRET_KEY=$(cat /home/${MY_USERNAME}/README | grep "Gogs secret key:" | awk -F ':' '{print $2}' | sed 's/^ *//')
else
GOGS_SECRET_KEY="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
echo "Gogs secret key:$GOGS_SECRET_KEY" >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
echo "Gogs secret key:${GOGS_SECRET_KEY}" >> /home/${MY_USERNAME}/README
chown $MY_USERNAME:$MY_USERNAME /home/${MY_USERNAME}/README
fi
# create the configuration
GOGS_CONFIG_PATH=/home/$GOGS_USERNAME/custom/conf
if [ ! -d $GOGS_CONFIG_PATH ]; then
mkdir -p $GOGS_CONFIG_PATH
fi
GOGS_CONFIG_FILE=$GOGS_CONFIG_PATH/app.ini
echo "RUN_USER = $GOGS_USERNAME" > $GOGS_CONFIG_FILE
echo 'RUN_MODE = prod' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[database]' >> $GOGS_CONFIG_FILE
echo 'DB_TYPE = mysql' >> $GOGS_CONFIG_FILE
echo 'HOST = 127.0.0.1:3306' >> $GOGS_CONFIG_FILE
echo 'NAME = gogs' >> $GOGS_CONFIG_FILE
echo 'USER = root' >> $GOGS_CONFIG_FILE
echo "PASSWD = $MARIADB_PASSWORD" >> $GOGS_CONFIG_FILE
echo 'SSL_MODE = disable' >> $GOGS_CONFIG_FILE
echo 'PATH = data/gogs.db' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[repository]' >> $GOGS_CONFIG_FILE
echo "ROOT = /home/$GOGS_USERNAME/gogs-repositories" >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[server]' >> $GOGS_CONFIG_FILE
if [[ $ONION_ONLY == 'no' ]]; then
echo "DOMAIN = ${GIT_DOMAIN_NAME}" >> $GOGS_CONFIG_FILE
GOGS_CONFIG_PATH=/home/${GOGS_USERNAME}/custom/conf
if [ ! -d ${GOGS_CONFIG_PATH} ]; then
mkdir -p ${GOGS_CONFIG_PATH}
fi
GOGS_CONFIG_FILE=${GOGS_CONFIG_PATH}/app.ini
echo "RUN_USER = $GOGS_USERNAME" > ${GOGS_CONFIG_FILE}
echo 'RUN_MODE = prod' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[database]' >> ${GOGS_CONFIG_FILE}
echo 'DB_TYPE = mysql' >> ${GOGS_CONFIG_FILE}
echo 'HOST = 127.0.0.1:3306' >> ${GOGS_CONFIG_FILE}
echo 'NAME = gogs' >> ${GOGS_CONFIG_FILE}
echo 'USER = root' >> ${GOGS_CONFIG_FILE}
echo "PASSWD = $MARIADB_PASSWORD" >> ${GOGS_CONFIG_FILE}
echo 'SSL_MODE = disable' >> ${GOGS_CONFIG_FILE}
echo 'PATH = data/gogs.db' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[repository]' >> ${GOGS_CONFIG_FILE}
echo "ROOT = /home/$GOGS_USERNAME/gogs-repositories" >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[server]' >> ${GOGS_CONFIG_FILE}
if [[ ${ONION_ONLY} == 'no' ]]; then
echo "DOMAIN = ${GIT_DOMAIN_NAME}" >> ${GOGS_CONFIG_FILE}
else
echo "DOMAIN = ${GIT_ONION_HOSTNAME}" >> $GOGS_CONFIG_FILE
fi
echo 'HTTP_PORT = 3000' >> $GOGS_CONFIG_FILE
echo "ROOT_URL = http://$GIT_DOMAIN_NAME/" >> $GOGS_CONFIG_FILE
echo "SSH_PORT = $SSH_PORT" >> $GOGS_CONFIG_FILE
echo 'SSH_DOMAIN = %(DOMAIN)s' >> $GOGS_CONFIG_FILE
echo "CERT_FILE = /etc/ssl/certs/${GIT_DOMAIN_NAME}.pem" >> $GOGS_CONFIG_FILE
echo "KEY_FILE = /etc/ssl/private/${GIT_DOMAIN_NAME}.key" >> $GOGS_CONFIG_FILE
echo 'DISABLE_ROUTER_LOG = true' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[session]' >> $GOGS_CONFIG_FILE
echo 'PROVIDER = file' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[log]' >> $GOGS_CONFIG_FILE
echo 'MODE = file' >> $GOGS_CONFIG_FILE
echo 'LEVEL = Info' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[security]' >> $GOGS_CONFIG_FILE
echo 'INSTALL_LOCK = true' >> $GOGS_CONFIG_FILE
echo "SECRET_KEY = $GOGS_SECRET_KEY" >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[service]' >> $GOGS_CONFIG_FILE
echo 'DISABLE_REGISTRATION = false' >> $GOGS_CONFIG_FILE
echo 'SHOW_REGISTRATION_BUTTON = true' >> $GOGS_CONFIG_FILE
echo 'REQUIRE_SIGNIN_VIEW = false' >> $GOGS_CONFIG_FILE
echo 'ENABLE_CAPTCHA = false' >> $GOGS_CONFIG_FILE
echo '' >> $GOGS_CONFIG_FILE
echo '[other]' >> $GOGS_CONFIG_FILE
echo 'SHOW_FOOTER_BRANDING = false' >> $GOGS_CONFIG_FILE
echo 'SHOW_FOOTER_VERSION = false' >> $GOGS_CONFIG_FILE
chmod 750 $GOGS_CONFIG_FILE
chown -R $GOGS_USERNAME:$GOGS_USERNAME /home/$GOGS_USERNAME
echo "DOMAIN = ${GIT_ONION_HOSTNAME}" >> ${GOGS_CONFIG_FILE}
fi
echo 'HTTP_PORT = 3000' >> ${GOGS_CONFIG_FILE}
echo "ROOT_URL = http://$GIT_DOMAIN_NAME/" >> ${GOGS_CONFIG_FILE}
echo "SSH_PORT = $SSH_PORT" >> ${GOGS_CONFIG_FILE}
echo 'SSH_DOMAIN = %(DOMAIN)s' >> ${GOGS_CONFIG_FILE}
echo "CERT_FILE = /etc/ssl/certs/${GIT_DOMAIN_NAME}.pem" >> ${GOGS_CONFIG_FILE}
echo "KEY_FILE = /etc/ssl/private/${GIT_DOMAIN_NAME}.key" >> ${GOGS_CONFIG_FILE}
echo 'DISABLE_ROUTER_LOG = true' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[session]' >> ${GOGS_CONFIG_FILE}
echo 'PROVIDER = file' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[log]' >> ${GOGS_CONFIG_FILE}
echo 'MODE = file' >> ${GOGS_CONFIG_FILE}
echo 'LEVEL = Info' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[security]' >> ${GOGS_CONFIG_FILE}
echo 'INSTALL_LOCK = true' >> ${GOGS_CONFIG_FILE}
echo "SECRET_KEY = $GOGS_SECRET_KEY" >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[service]' >> ${GOGS_CONFIG_FILE}
echo 'DISABLE_REGISTRATION = false' >> ${GOGS_CONFIG_FILE}
echo 'SHOW_REGISTRATION_BUTTON = true' >> ${GOGS_CONFIG_FILE}
echo 'REQUIRE_SIGNIN_VIEW = false' >> ${GOGS_CONFIG_FILE}
echo 'ENABLE_CAPTCHA = false' >> ${GOGS_CONFIG_FILE}
echo '' >> ${GOGS_CONFIG_FILE}
echo '[other]' >> ${GOGS_CONFIG_FILE}
echo 'SHOW_FOOTER_BRANDING = false' >> ${GOGS_CONFIG_FILE}
echo 'SHOW_FOOTER_VERSION = false' >> ${GOGS_CONFIG_FILE}
chmod 750 ${GOGS_CONFIG_FILE}
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
systemctl restart gogs
if ! grep -q "gogs domain:" $COMPLETION_FILE; then
echo "gogs domain:$GIT_DOMAIN_NAME" >> $COMPLETION_FILE
if ! grep -q "gogs domain:" ${COMPLETION_FILE}; then
echo "gogs domain:${GIT_DOMAIN_NAME}" >> ${COMPLETION_FILE}
else
sed -i "s|gogs domain.*|gogs domain:$GIT_DOMAIN_NAME|g" $COMPLETION_FILE
sed -i "s|gogs domain.*|gogs domain:${GIT_DOMAIN_NAME}|g" ${COMPLETION_FILE}
fi
function_check configure_firewall_for_git
configure_firewall_for_git
if ! grep -q "gogs version:" $COMPLETION_FILE; then
echo "gogs version:$GOGS_VERSION" >> $COMPLETION_FILE
if ! grep -q "gogs version:" ${COMPLETION_FILE}; then
echo "gogs version:${GOGS_VERSION}" >> ${COMPLETION_FILE}
else
sed -i "s|gogs version.*|gogs version:$GOGS_VERSION|g" $COMPLETION_FILE
sed -i "s|gogs version.*|gogs version:${GOGS_VERSION}|g" ${COMPLETION_FILE}
fi
}

158
src/freedombone-app-hubzilla

@ -40,6 +40,16 @@ HUBZILLA_ADMIN_PASSWORD=
HUBZILLA_COMMIT='8aee932525d0bc341713fe7052e2a5ab318a69c0'
HUBZILLA_ADDONS_COMMIT='4456f097e3faf2adeab696ad08e3f213e82199bd'
hubzilla_variables=(ONION_ONLY
HUBZILLA_DOMAIN_NAME
HUBZILLA_CODE
DDNS_PROVIDER
MY_USERNAME
HUBZILLA_REPO
HUBZILLA_COMMIT
HUBZILLA_ADDONS_REPO
HUBZILLA_ADDONS_COMMIT)
function hubzilla_renew_cert {
dialog --title $"Renew SSL certificate" \
--backtitle $"Freedombone Control Panel" \
@ -126,21 +136,6 @@ function configure_interactive_hubzilla {
}
function install_interactive_hubzilla {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [[ $ONION_ONLY != "no" ]]; then
HUBZILLA_DOMAIN_NAME='hubzilla.local'
else
@ -250,10 +245,6 @@ function reconfigure_hubzilla {
}
function upgrade_hubzilla {
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
function_check set_repo_commit
@ -269,88 +260,66 @@ function upgrade_hubzilla {
}
function backup_local_hubzilla {
if grep -q "hubzilla domain" $COMPLETION_FILE; then
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
hubzilla_path=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
if [ -d $hubzilla_path ]; then
echo $"Backing up Hubzilla"
function_check backup_database_to_usb
backup_database_to_usb hubzilla
backup_directory_to_usb $hubzilla_path hubzilla
hubzilla_path=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
if [ -d $hubzilla_path ]; then
function_check backup_database_to_usb
backup_database_to_usb hubzilla
echo $"Hubzilla backup complete"
fi
backup_directory_to_usb $hubzilla_path hubzilla
fi
}
function restore_local_hubzilla {
if ! grep -q "hubzilla domain" $COMPLETION_FILE; then
return
fi
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
if [ $HUBZILLA_DOMAIN_NAME ]; then
echo $"Restoring Hubzilla"
temp_restore_dir=/root/temphubzilla
hubzilla_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
function_check hubzilla_create_database
hubzilla_create_database
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
if [ -d $USB_MOUNT/backup/hubzilla ]; then
if [ ! -d $hubzilla_dir/store/[data]/smarty3 ]; then
mkdir -p $hubzilla_dir/store/[data]/smarty3
fi
chmod 777 $hubzilla_dir/store/[data]/smarty3
chown -R www-data:www-data $hubzilla_dir/*
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
temp_restore_dir=/root/temphubzilla
hubzilla_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
function_check hubzilla_create_database
hubzilla_create_database
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
if [ -d $USB_MOUNT/backup/hubzilla ]; then
if [ ! -d $hubzilla_dir/store/[data]/smarty3 ]; then
mkdir -p $hubzilla_dir/store/[data]/smarty3
fi
chmod 777 $hubzilla_dir/store/[data]/smarty3
chown -R www-data:www-data $hubzilla_dir/*
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
echo $"Restore of Hubzilla complete"
fi
}
function backup_remote_hubzilla {
if grep -q "hubzilla domain" $COMPLETION_FILE; then
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
temp_backup_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
if [ -d $temp_backup_dir ]; then
suspend_site ${HUBZILLA_DOMAIN_NAME}
backup_database_to_friend hubzilla
echo "Backing up Hubzilla installation"
backup_directory_to_friend $temp_backup_dir hubzilla
restart_site
echo "Backup of Hubzilla complete"
else
echo $"Hubzilla domain specified but not found in /var/www/${HUBZILLA_DOMAIN_NAME}"
exit 2578
fi
temp_backup_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
if [ -d $temp_backup_dir ]; then
suspend_site ${HUBZILLA_DOMAIN_NAME}
backup_database_to_friend hubzilla
echo "Backing up Hubzilla installation"
backup_directory_to_friend $temp_backup_dir hubzilla
restart_site
echo "Backup of Hubzilla complete"
else
echo $"Hubzilla domain specified but not found in /var/www/${HUBZILLA_DOMAIN_NAME}"
exit 2578
fi
}
function restore_remote_hubzilla {
if grep -q "hubzilla domain" $COMPLETION_FILE; then
echo $"Restoring Hubzilla"
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
function_check restore_database_from_friend
function_check hubzilla_create_database
hubzilla_create_database
restore_database_from_friend hubzilla ${HUBZILLA_DOMAIN_NAME}
if [ -d $SERVER_DIRECTORY/backup/hubzilla ]; then
if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
fi
chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
fi
if [ -d /root/temphubzilla ]; then
rm -rf /root/temphubzilla
function_check restore_database_from_friend
function_check hubzilla_create_database
hubzilla_create_database
restore_database_from_friend hubzilla ${HUBZILLA_DOMAIN_NAME}
if [ -d $SERVER_DIRECTORY/backup/hubzilla ]; then
if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
fi
echo $"Restore of Hubzilla complete"
chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
fi
if [ -d /root/temphubzilla ]; then
rm -rf /root/temphubzilla
fi
}
@ -359,7 +328,6 @@ function remove_hubzilla {
return
fi
echo $'Removing Hubzilla'
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "hubzilla domain" | awk -F ':' '{print $2}')
nginx_dissite $HUBZILLA_DOMAIN_NAME
if [ -d /var/www/$HUBZILLA_DOMAIN_NAME ]; then
rm -rf /var/www/$HUBZILLA_DOMAIN_NAME
@ -376,22 +344,6 @@ function remove_hubzilla {
}
function install_hubzilla {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [ ! $HUBZILLA_DOMAIN_NAME ]; then
return
fi

5
src/freedombone-app-ipfs

@ -41,6 +41,11 @@ IPFS_JS_RONIN_VERSION='0.3.11'
IPFS_KEY_LENGTH=2048
IPFS_GO_VERSION=0.4.2
ipfs_variables=(IPFS_COMMIT
IPFS_GO_VERSION
IPFS_KEY_LENGTH
IPFS_PORT)
function install_interactive_ipfs {
echo -n ''
}

343
src/freedombone-app-irc

@ -36,14 +36,22 @@ IRC_ONION_PORT=6697
# An optional password to log into IRC. This applies to all users
IRC_PASSWORD=
irc_variables=(MY_USERNAME
MY_NAME
IRC_PORT
IRC_PASSWORD
DEFAULT_DOMAIN_NAME
INSTALLED_WITHIN_DOCKER
ONION_ONLY)
function remove_user_irc {
remove_username="$1"
if [ -d /home/$remove_username/.irssi ]; then
rm -rf /home/$remove_username/.irssi
if [ -d /home/${remove_username}/.irssi ]; then
rm -rf /home/${remove_username}/.irssi
fi
if [ -d /home/$remove_username/irclogs ]; then
rm -rf /home/$remove_username/irclogs
if [ -d /home/${remove_username}/irclogs ]; then
rm -rf /home/${remove_username}/irclogs
fi
}
@ -51,74 +59,71 @@ function add_user_irc {
new_username="$1"
new_user_password="$2"
if grep -q "IRC_PORT" $CONFIGURATION_FILE; then
IRC_PORT=$(grep "IRC_PORT" $CONFIGURATION_FILE | head -n 1 | awk -F '=' '{print $2}')
fi
IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
if [ ${#IRC_PASSWORD} -lt 2 ]; then
IRC_PASSWORD=
fi
if [ ! -d /home/$new_username/.irssi ]; then
mkdir /home/$new_username/.irssi
if [ ! -d /home/${new_username}/.irssi ]; then
mkdir /home/${new_username}/.irssi
fi
echo 'servers = (' > /home/$new_username/.irssi/config
echo ' {' >> /home/$new_username/.irssi/config
echo ' address = "chat.freenode.net";' >> /home/$new_username/.irssi/config
echo ' chatnet = "Freenode";' >> /home/$new_username/.irssi/config
echo ' port = "6667";' >> /home/$new_username/.irssi/config
echo ' autoconnect = "no";' >> /home/$new_username/.irssi/config
echo ' },' >> /home/$new_username/.irssi/config
echo ' {' >> /home/$new_username/.irssi/config
echo ' address = "irc.oftc.net";' >> /home/$new_username/.irssi/config
echo ' chatnet = "OFTC";' >> /home/$new_username/.irssi/config
echo ' port = "6667";' >> /home/$new_username/.irssi/config
echo ' autoconnect = "yes";' >> /home/$new_username/.irssi/config
echo ' },' >> /home/$new_username/.irssi/config
echo ' {' >> /home/$new_username/.irssi/config
echo " address = \"${HOSTNAME}\";" >> /home/$new_username/.irssi/config
echo ' chatnet = "Freedombone";' >> /home/$new_username/.irssi/config
echo " port = \"${IRC_PORT}\";" >> /home/$new_username/.irssi/config
echo ' use_ssl = "yes";' >> /home/$new_username/.irssi/config
echo ' ssl_verify = "no";' >> /home/$new_username/.irssi/config
echo ' autoconnect = "yes";' >> /home/$new_username/.irssi/config
echo ' }' >> /home/$new_username/.irssi/config
echo ');' >> /home/$new_username/.irssi/config
echo '' >> /home/$new_username/.irssi/config
echo 'chatnets = {' >> /home/$new_username/.irssi/config
echo ' Freedombone = {' >> /home/$new_username/.irssi/config
echo ' type = "IRC";' >> /home/$new_username/.irssi/config
echo ' max_kicks = "1";' >> /home/$new_username/.irssi/config
echo ' max_msgs = "4";' >> /home/$new_username/.irssi/config
echo ' max_whois = "1";' >> /home/$new_username/.irssi/config
echo ' };' >> /home/$new_username/.irssi/config
echo ' Freenode = {' >> /home/$new_username/.irssi/config
echo ' type = "IRC";' >> /home/$new_username/.irssi/config
echo ' max_kicks = "1";' >> /home/$new_username/.irssi/config
echo ' max_msgs = "4";' >> /home/$new_username/.irssi/config
echo ' max_whois = "1";' >> /home/$new_username/.irssi/config
echo ' };' >> /home/$new_username/.irssi/config
echo ' OFTC = {' >> /home/$new_username/.irssi/config
echo ' type = "IRC";' >> /home/$new_username/.irssi/config
echo ' max_kicks = "1";' >> /home/$new_username/.irssi/config
echo ' max_msgs = "1";' >> /home/$new_username/.irssi/config
echo ' max_whois = "1";' >> /home/$new_username/.irssi/config
echo ' };' >> /home/$new_username/.irssi/config
echo '};' >> /home/$new_username/.irssi/config
echo '' >> /home/$new_username/.irssi/config
echo 'channels = (' >> /home/$new_username/.irssi/config
echo ' { name = "#freedombone"; chatnet = "Freedombone"; autojoin = "Yes"; },' >> /home/$new_username/.irssi/config
echo ');' >> /home/$new_username/.irssi/config
echo '' >> /home/$new_username/.irssi/config
echo 'settings = {' >> /home/$new_username/.irssi/config
echo " core = { real_name = \"$MY_NAME\"; user_name = \"$new_username\"; nick = \"$new_username\"; };" >> /home/$new_username/.irssi/config
echo ' "fe-text" = { actlist_sort = "refnum"; };' >> /home/$new_username/.irssi/config
echo 'servers = (' > /home/${new_username}/.irssi/config
echo ' {' >> /home/${new_username}/.irssi/config
echo ' address = "chat.freenode.net";' >> /home/${new_username}/.irssi/config
echo ' chatnet = "Freenode";' >> /home/${new_username}/.irssi/config
echo ' port = "6667";' >> /home/${new_username}/.irssi/config
echo ' autoconnect = "no";' >> /home/${new_username}/.irssi/config
echo ' },' >> /home/${new_username}/.irssi/config
echo ' {' >> /home/${new_username}/.irssi/config
echo ' address = "irc.oftc.net";' >> /home/${new_username}/.irssi/config
echo ' chatnet = "OFTC";' >> /home/${new_username}/.irssi/config
echo ' port = "6667";' >> /home/${new_username}/.irssi/config
echo ' autoconnect = "yes";' >> /home/${new_username}/.irssi/config
echo ' },' >> /home/${new_username}/.irssi/config
echo ' {' >> /home/${new_username}/.irssi/config
echo " address = \"${HOSTNAME}\";" >> /home/${new_username}/.irssi/config
echo ' chatnet = "Freedombone";' >> /home/${new_username}/.irssi/config
echo " port = \"${IRC_PORT}\";" >> /home/${new_username}/.irssi/config
echo ' use_ssl = "yes";' >> /home/${new_username}/.irssi/config
echo ' ssl_verify = "no";' >> /home/${new_username}/.irssi/config
echo ' autoconnect = "yes";' >> /home/${new_username}/.irssi/config
echo ' }' >> /home/${new_username}/.irssi/config
echo ');' >> /home/${new_username}/.irssi/config
echo '' >> /home/${new_username}/.irssi/config
echo 'chatnets = {' >> /home/${new_username}/.irssi/config
echo ' Freedombone = {' >> /home/${new_username}/.irssi/config
echo ' type = "IRC";' >> /home/${new_username}/.irssi/config
echo ' max_kicks = "1";' >> /home/${new_username}/.irssi/config
echo ' max_msgs = "4";' >> /home/${new_username}/.irssi/config
echo ' max_whois = "1";' >> /home/${new_username}/.irssi/config
echo ' };' >> /home/${new_username}/.irssi/config
echo ' Freenode = {' >> /home/${new_username}/.irssi/config
echo ' type = "IRC";' >> /home/${new_username}/.irssi/config
echo ' max_kicks = "1";' >> /home/${new_username}/.irssi/config
echo ' max_msgs = "4";' >> /home/${new_username}/.irssi/config
echo ' max_whois = "1";' >> /home/${new_username}/.irssi/config
echo ' };' >> /home/${new_username}/.irssi/config
echo ' OFTC = {' >> /home/${new_username}/.irssi/config
echo ' type = "IRC";' >> /home/${new_username}/.irssi/config
echo ' max_kicks = "1";' >> /home/${new_username}/.irssi/config
echo ' max_msgs = "1";' >> /home/${new_username}/.irssi/config
echo ' max_whois = "1";' >> /home/${new_username}/.irssi/config
echo ' };' >> /home/${new_username}/.irssi/config
echo '};' >> /home/${new_username}/.irssi/config
echo '' >> /home/${new_username}/.irssi/config
echo 'channels = (' >> /home/${new_username}/.irssi/config
echo ' { name = "#freedombone"; chatnet = "Freedombone"; autojoin = "Yes"; },' >> /home/${new_username}/.irssi/config
echo ');' >> /home/${new_username}/.irssi/config
echo '' >> /home/${new_username}/.irssi/config
echo 'settings = {' >> /home/${new_username}/.irssi/config
echo " core = { real_name = \"$MY_NAME\"; user_name = \"$new_username\"; nick = \"$new_username\"; };" >> /home/${new_username}/.irssi/config
echo ' "fe-text" = { actlist_sort = "refnum"; };' >> /home/${new_username}/.irssi/config
echo '};' >> /home/$new_username/.irssi/config
echo 'ignores = ( { level = "CTCPS"; } );' >> /home/$new_username/.irssi/config
echo 'ignores = ( { level = "CTCPS"; } );' >> /home/${new_username}/.irssi/config
chown -R $new_username:$new_username /home/$new_username/.irssi
chown -R ${new_username}:${new_username} /home/${new_username}/.irssi
echo '0'
}
@ -149,9 +154,9 @@ function irc_set_global_password {
for d in /home/*/ ; do
IRC_USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$IRC_USERNAME") == "1" ]]; then
if [ -f /home/$IRC_USERNAME/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/$IRC_USERNAME/.irssi/config
chown -R $IRC_USERNAME:$IRC_USERNAME /home/$IRC_USERNAME/.irssi
if [ -f /home/${IRC_USERNAME}/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/${IRC_USERNAME}/.irssi/config
chown -R ${IRC_USERNAME}:${IRC_USERNAME} /home/${IRC_USERNAME}/.irssi
fi
fi
done
@ -238,38 +243,38 @@ function remove_irc {
if [ -d /etc/ngircd ]; then
rm -rf /etc/ngircd
fi
iptables -D INPUT -p tcp --dport $IRC_PORT -j ACCEPT
iptables -D INPUT -p tcp --dport 1024:65535 --sport $IRC_PORT -j ACCEPT
iptables -D INPUT -p tcp --dport ${IRC_PORT} -j ACCEPT
iptables -D INPUT -p tcp --dport 1024:65535 --sport ${IRC_PORT} -j ACCEPT
function_check save_firewall_settings
save_firewall_settings
function_check remove_onion_service
remove_onion_service irc ${IRC_ONION_PORT}
sed -i '/install_irc/d' $COMPLETION_FILE
sed -i '/IRC /d' $COMPLETION_FILE
sed -i '/configure_firewall_for_irc/d' $COMPLETION_FILE
sed -i '/install_irc/d' ${COMPLETION_FILE}
sed -i '/IRC /d' ${COMPLETION_FILE}
sed -i '/configure_firewall_for_irc/d' ${COMPLETION_FILE}
}
function configure_firewall_for_irc {
if [ ! -d /etc/ngircd ]; then
return
fi
if grep -Fxq "configure_firewall_for_irc" $COMPLETION_FILE; then
if grep -Fxq "configure_firewall_for_irc" ${COMPLETION_FILE}; then
return
fi
if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
if [[ ${INSTALLED_WITHIN_DOCKER} == "yes" ]]; then
# docker does its own firewalling
return
fi
if [[ $ONION_ONLY != "no" ]]; then
if [[ ${ONION_ONLY} != "no" ]]; then
return
fi
iptables -A INPUT -p tcp --dport $IRC_PORT -j ACCEPT
iptables -I INPUT -p tcp --dport 1024:65535 --sport $IRC_PORT -j ACCEPT
iptables -A INPUT -p tcp --dport ${IRC_PORT} -j ACCEPT
iptables -I INPUT -p tcp --dport 1024:65535 --sport ${IRC_PORT} -j ACCEPT
function_check save_firewall_settings
save_firewall_settings
OPEN_PORTS+=("IRC $IRC_PORT")
echo 'configure_firewall_for_irc' >> $COMPLETION_FILE
echo 'configure_firewall_for_irc' >> ${COMPLETION_FILE}
}
function install_irc_server {
@ -284,18 +289,18 @@ function install_irc_server {
fi
if [ ! -f /etc/ssl/certs/ngircd.dhparam ]; then
${PROJECT_NAME}-addcert -h ngircd --dhkey $DH_KEYLENGTH
${PROJECT_NAME}-addcert -h ngircd --dhkey ${DH_KEYLENGTH}
function_check check_certificates
check_certificates ngircd
fi
DEFAULTDOMAIN=$DEFAULT_DOMAIN_NAME
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
DEFAULTDOMAIN=${DEFAULT_DOMAIN_NAME}
if [[ ${SYSTEM_TYPE} == "$VARIANT_MESH" ]]; then
DEFAULTDOMAIN="${DEFAULT_DOMAIN_NAME}.local"
fi
# create a login password if needed
if [ ! $IRC_PASSWORD ]; then
if [ ! ${IRC_PASSWORD} ]; then
IRC_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
@ -312,15 +317,15 @@ function install_irc_server {
sed -i 's|;CertFile = /etc/ssl/certs/server.crt|CertFile = /etc/ssl/certs/ngircd.crt|g' /etc/ngircd/ngircd.conf
sed -i 's|;DHFile = /etc/ngircd/dhparams.pem|DHFile = /etc/ssl/certs/ngircd.dhparam|g' /etc/ngircd/ngircd.conf
sed -i 's|;KeyFile = /etc/ssl/private/server.key|KeyFile = /etc/ssl/private/ngircd.key|g' /etc/ngircd/ngircd.conf
sed -i "s/;Ports =.*/Ports = $IRC_PORT/1" /etc/ngircd/ngircd.conf
sed -i "s/;Ports =.*/Ports = $IRC_PORT/2" /etc/ngircd/ngircd.conf
sed -i "s/;Ports =.*/Ports = ${IRC_PORT}/1" /etc/ngircd/ngircd.conf
sed -i "s/;Ports =.*/Ports = ${IRC_PORT}/2" /etc/ngircd/ngircd.conf
sed -i "s/;Name = #ngircd/Name = #${PROJECT_NAME}/g" /etc/ngircd/ngircd.conf
sed -i "s/;Topic = Our ngircd testing channel/Topic = ${PROJECT_NAME} chat channel/g" /etc/ngircd/ngircd.conf
sed -i 's/;MaxUsers = 23/MaxUsers = 23/g' /etc/ngircd/ngircd.conf
sed -i "s|;KeyFile = /etc/ngircd/#chan.key|KeyFile = /etc/ngircd/#${PROJECT_NAME}.key|g" /etc/ngircd/ngircd.conf
sed -i "s/;CloakHost = cloaked.host/CloakHost = ${PROJECT_NAME}/g" /etc/ngircd/ngircd.conf
IRC_SALT="$(create_password 30)"
if [ -f $IMAGE_PASSWORD_FILE ]; then
if [ -f ${IMAGE_PASSWORD_FILE} ]; then
IRC_OPERATOR_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
IRC_OPERATOR_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
@ -332,11 +337,11 @@ function install_irc_server {
sed -i "s/;Name = TheOper/Name = $MY_USERNAME/g" /etc/ngircd/ngircd.conf
sed -i "s/;Password = ThePwd/Password = $IRC_OPERATOR_PASSWORD/g" /etc/ngircd/ngircd.conf
sed -i 's|;Listen =.*|Listen = 0.0.0.0,0.0.0.0:9050,127.0.0.1,127.0.0.1:9050|g' /etc/ngircd/ngircd.conf
if [ $IRC_PASSWORD ]; then
if [ ${IRC_PASSWORD} ]; then
sed -i "0,/RE/s/Password =.*/Password =$IRC_PASSWORD/" /etc/ngircd/ngircd.conf
fi
# If we are on a mesh then DNS is not available
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
if [[ ${SYSTEM_TYPE} == "$VARIANT_MESH" ]]; then
sed -i "s/;DNS =.*/DNS = no/g" /etc/ngircd/ngircd.conf
fi
# upgrade a cypher
@ -353,30 +358,30 @@ function install_irc_server {
add_watchdog_daemon ngircd
if ! grep -q $"IRC Server" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo $'IRC Server' >> /home/$MY_USERNAME/README
echo '==========' >> /home/$MY_USERNAME/README
echo $'To connect to your IRC server in irssi:' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
if [[ $ONION_ONLY != 'yes' ]]; then
echo " irssi" >> /home/$MY_USERNAME/README
echo " /server add -auto -ssl $DEFAULTDOMAIN $IRC_PORT" >> /home/$MY_USERNAME/README
echo " /connect $DEFAULT_DOMAIN_NAME" >> /home/$MY_USERNAME/README
if ! grep -q $"IRC Server" /home/${MY_USERNAME}/README; then
echo '' >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
echo $'IRC Server' >> /home/${MY_USERNAME}/README
echo '==========' >> /home/${MY_USERNAME}/README
echo $'To connect to your IRC server in irssi:' >> /home/${MY_USERNAME}/README
echo '' >> /home/${MY_USERNAME}/README
if [[ ${ONION_ONLY} != 'yes' ]]; then
echo " irssi" >> /home/${MY_USERNAME}/README
echo " /server add -auto -ssl $DEFAULTDOMAIN $IRC_PORT" >> /home/${MY_USERNAME}/README
echo " /connect $DEFAULT_DOMAIN_NAME" >> /home/${MY_USERNAME}/README
else
echo " usetorwith irssi" >> /home/$MY_USERNAME/README
echo " /server add -auto $IRC_ONION_HOSTNAME $IRC_PORT" >> /home/$MY_USERNAME/README
echo " /connect $IRC_ONION_HOSTNAME" >> /home/$MY_USERNAME/README
echo " usetorwith irssi" >> /home/${MY_USERNAME}/README
echo " /server add -auto $IRC_ONION_HOSTNAME $IRC_PORT" >> /home/${MY_USERNAME}/README
echo " /connect $IRC_ONION_HOSTNAME" >> /home/${MY_USERNAME}/README
fi
echo " /join #${PROJECT_NAME}" >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
echo " /join #${PROJECT_NAME}" >> /home/${MY_USERNAME}/README
chown ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/README
chmod 600 /home/${MY_USERNAME}/README
fi
function_check configure_firewall_for_irc
configure_firewall_for_irc
echo 'install_irc_server' >> $COMPLETION_FILE
install_completed irc_server
}
function install_irc_client {
@ -385,76 +390,76 @@ function install_irc_client {