From c6e9f60c137064aa848ae712354c42b0dc6a8ce1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 11:46:09 +0000 Subject: [PATCH 01/14] edith notes app --- src/freedombone-app-edith | 445 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 445 insertions(+) create mode 100755 src/freedombone-app-edith diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith new file mode 100755 index 00000000..3f9c9ed2 --- /dev/null +++ b/src/freedombone-app-edith @@ -0,0 +1,445 @@ +#!/bin/bash +# +# .---. . . +# | | | +# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. +# | | (.-' (.-' ( | ( )| | | | )( )| | (.-' +# ' ' --' --' -' - -' ' ' -' -' -' ' - --' +# +# Freedom in the Cloud +# +# Edith: an ultra simple notes application +# +# License +# ======= +# +# Copyright (C) 2018 Bob Mottram +# +# 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 . + +VARIANTS='full full-vim writer' + +IN_DEFAULT_INSTALL=0 +SHOW_ON_ABOUT=1 + +EDITH_REPO="https://github.com/sunny/edith" +EDITH_COMMIT='59f571e24be9e75d127a0f130591acf8d7a86ce3' +EDITH_DOMAIN_NAME= +EDITH_CODE= +EDITH_ONION_PORT=8278 +EDITH_LOGIN_TEXT=$"Edith login" + +edith_variables=(MY_USERNAME + MY_EMAIL_ADDRESS + ONION_ONLY + EDITH_DOMAIN_NAME + EDITH_CODE + DEFAULT_LANGUAGE) + +function change_password_edith { + curr_username="$1" + new_user_password="$2" + + sed -i "/${curr_username}:/d" /etc/nginx/.edithpasswd + echo -n "$new_user_password" | htpasswd -i -s -c /etc/nginx/.edithpasswd ${curr_username} + + ${PROJECT_NAME}-pass -u $MY_USERNAME -a ${curr_username} -p "$new_user_password" +} + +function logging_on_edith { + echo -n '' +} + +function logging_off_edith { + echo -n '' +} + +function reconfigure_edith { + echo -n '' +} + +function edith_enable_login { + read_config_param EDITH_DOMAIN_NAME + + dialog --title $"Enable Edith login" \ + --backtitle $"Freedombone Control Panel" \ + --defaultno \ + --yesno $"\nDo you want to add a login so that random web users can't access your notes?" 10 60 + sel=$? + case $sel in + 0) if grep -q '#auth_basic' /etc/nginx/sites-available/$EDITH_DOMAIN_NAME; then + sed -i 's|#auth_basic|auth_basic|g' /etc/nginx/sites-available/$EDITH_DOMAIN_NAME + systemctl restart nginx + fi + read_config_param $MY_USERNAME + EDITH_PASSWORD=$(${PROJECT_NAME}-pass -u $MY_USERNAME -a edith) + dialog --title $"Enable Edith login" \ + --msgbox $"Edith logins are now enabled with the password $EDITH_PASSWORD" 6 65 + EDITH__PASSWORD= + ;; + 1) if ! grep -q '#auth_basic' /etc/nginx/sites-available/$EDITH_DOMAIN_NAME; then + sed -i 's|auth_basic|#auth_basic|g' /etc/nginx/sites-available/$EDITH_DOMAIN_NAME + systemctl restart nginx + fi + dialog --title $"Disable Edith login" \ + --msgbox $"Edith logins are now disabled. Anyone can access your stream." 6 65 + ;; + esac +} + +function edith_browse { + read_config_param EDITH_DOMAIN_NAME + cd /var/www/$EDITH_DOMAIN_NAME/htdocs/data + editor /var/www/$EDITH_DOMAIN_NAME/htdocs/data +} + +function configure_interactive_edith { + while true + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Control Panel" \ + --title $"Edith" \ + --radiolist $"Choose an operation:" 10 50 3 \ + 1 $"Enable login" off \ + 2 $"Browse notes" off \ + 3 $"Exit" on 2> $data + sel=$? + case $sel in + 1) break;; + 255) break;; + esac + case $(cat $data) in + 1) edith_enable_login;; + 2) edith_browse;; + 3) break;; + esac + done +} + +function upgrade_edith { + CURR_EDITH_COMMIT=$(get_completion_param "edith commit") + if [[ "$CURR_EDITH_COMMIT" == "$EDITH_COMMIT" ]]; then + return + fi + + read_config_param EDITH_DOMAIN_NAME + + # update to the next commit + function_check set_repo_commit + set_repo_commit /var/www/$EDITH_DOMAIN_NAME/htdocs "edith commit" "$EDITH_COMMIT" $EDITH_REPO + + chown -R www-data:www-data /var/www/$EDITH_DOMAIN_NAME/htdocs + chmod a+w /var/www/$EDITH_DOMAIN_NAME/htdocs/data +} + +function backup_local_edith { + read_config_param EDITH_DOMAIN_NAME + + function_check suspend_site + suspend_site ${EDITH_DOMAIN_NAME} + + source_directory=/var/www/${EDITH_DOMAIN_NAME}/htdocs/data + + function_check backup_directory_to_usb + dest_directory=edith + backup_directory_to_usb $source_directory $dest_directory + + function_check restart_site + restart_site +} + +function restore_local_edith { + read_config_param EDITH_DOMAIN_NAME + + temp_restore_dir=/root/tempedith + edith_dir=/var/www/${EDITH_DOMAIN_NAME}/htdocs/data + + function_check restore_directory_from_usb + restore_directory_from_usb $temp_restore_dir edith + if [ -d $temp_restore_dir ]; then + if [ -d cp $temp_restore_dir$edith_dir ]; then + cp -rp $temp_restore_dir$edith_dir $edith_dir/ + else + if [ ! -d $edith_dir ]; then + mkdir $edith_dir + chmod a+w $edith_dir + fi + cp -rp $temp_restore_dir/* $edith_dir + fi + chown -R www-data:www-data $edith_dir + rm -rf $temp_restore_dir + fi +} + +function backup_remote_edith { + read_config_param EDITH_DOMAIN_NAME + + function_check suspend_site + suspend_site ${EDITH_DOMAIN_NAME} + + source_directory=/var/www/${EDITH_DOMAIN_NAME}/htdocs/data + + function_check backup_directory_to_friend + dest_directory=edith + backup_directory_to_friend $source_directory $dest_directory + + function_check restart_site + restart_site +} + +function restore_remote_edith { + read_config_param EDITH_DOMAIN_NAME + + temp_restore_dir=/root/tempedith + edith_dir=/var/www/${EDITH_DOMAIN_NAME}/htdocs/data + + function_check restore_directory_from_friend + restore_directory_from_friend $temp_restore_dir edith + if [ -d $temp_restore_dir ]; then + if [ -d cp $temp_restore_dir$edith_dir ]; then + cp -rp $temp_restore_dir$edith_dir $edith_dir/ + else + if [ ! -d $edith_dir ]; then + mkdir $edith_dir + chmod a+w $edith_dir + fi + cp -rp $temp_restore_dir/* $edith_dir + fi + chown -R www-data:www-data $edith_dir + rm -rf $temp_restore_dir + fi +} + +function remove_edith { + nginx_dissite $EDITH_DOMAIN_NAME + + if [ -f /etc/nginx/sites-available/$EDITH_DOMAIN_NAME ]; then + rm /etc/nginx/sites-available/$EDITH_DOMAIN_NAME + fi + + if [ -d /var/www/$EDITH_DOMAIN_NAME ]; then + rm -rf /var/www/$EDITH_DOMAIN_NAME + fi + + function_check remove_onion_service + remove_onion_service edith ${EDITH_ONION_PORT} + sed -i '/edith/d' $COMPLETION_FILE + + if [ -f /etc/nginx/.edithpasswd ]; then + rm /etc/nginx/.edithpasswd + fi + + function_check remove_nodejs + remove_nodejs edith +} + +function install_edith { + apt-get -yq install php-gettext php-curl php-gd php-mysql git curl + apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl + + function_check install_nodejs + install_nodejs edith + + if [ ! ${EDITH_PASSWORD} ]; then + if [ -f ${IMAGE_PASSWORD_FILE} ]; then + EDITH_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" + else + EDITH_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" + fi + fi + + EDITH_ONION_HOSTNAME=$(add_onion_service edith 80 ${EDITH_ONION_PORT}) + + if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then + mkdir -p /var/www/$EDITH_DOMAIN_NAME/htdocs + fi + if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then + + if [ -d /repos/edith ]; then + mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs + cp -r -p /repos/edith/. /var/www/$EDITH_DOMAIN_NAME/htdocs + cd /var/www/$EDITH_DOMAIN_NAME/htdocs + git pull + else + function_check git_clone + git_clone $EDITH_REPO /var/www/$EDITH_DOMAIN_NAME/htdocs + fi + + if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then + echo $'Unable to clone edith repo' + exit 537593569 + fi + fi + + cd /var/www/$EDITH_DOMAIN_NAME/htdocs + git checkout $EDITH_COMMIT -b $EDITH_COMMIT + set_completion_param "edith commit" "$EDITH_COMMIT" + + if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs/data ]; then + mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs/data + fi + + edith_nginx_site=/etc/nginx/sites-available/$EDITH_DOMAIN_NAME + if [[ $ONION_ONLY == "no" ]]; then + function_check nginx_http_redirect + nginx_http_redirect $EDITH_DOMAIN_NAME "index index.php" + echo 'server {' >> $edith_nginx_site + echo ' listen 443 ssl;' >> $edith_nginx_site + echo ' listen [::]:443 ssl;' >> $edith_nginx_site + echo " server_name $EDITH_DOMAIN_NAME;" >> $edith_nginx_site + echo '' >> $edith_nginx_site + function_check nginx_compress + nginx_compress $EDITH_DOMAIN_NAME + echo '' >> $edith_nginx_site + echo ' # Security' >> $edith_nginx_site + function_check nginx_ssl + nginx_ssl $EDITH_DOMAIN_NAME + + function_check nginx_disable_sniffing + nginx_disable_sniffing $EDITH_DOMAIN_NAME + + echo ' add_header Strict-Transport-Security max-age=15768000;' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' access_log /dev/null;' >> $edith_nginx_site + echo ' error_log /dev/null;' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo " root /var/www/$EDITH_DOMAIN_NAME/htdocs;" >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' index index.php;' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # PHP' >> $edith_nginx_site + echo ' location ~ \.php {' >> $edith_nginx_site + echo ' include snippets/fastcgi-php.conf;' >> $edith_nginx_site + echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $edith_nginx_site + echo ' fastcgi_read_timeout 30;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # Location' >> $edith_nginx_site + echo ' location / {' >> $edith_nginx_site + function_check nginx_limits + nginx_limits $EDITH_DOMAIN_NAME '15m' + echo ' try_files $uri $uri/ @edith;' >> $edith_nginx_site + echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site + echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # Restrict access that is unnecessary anyway' >> $edith_nginx_site + echo ' location ~ /\.(ht|git) {' >> $edith_nginx_site + echo ' deny all;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '}' >> $edith_nginx_site + else + echo -n '' > $edith_nginx_site + fi + echo 'server {' >> $edith_nginx_site + echo " listen 127.0.0.1:$EDITH_ONION_PORT default_server;" >> $edith_nginx_site + echo " server_name $EDITH_ONION_HOSTNAME;" >> $edith_nginx_site + echo '' >> $edith_nginx_site + function_check nginx_compress + nginx_compress $EDITH_DOMAIN_NAME + echo '' >> $edith_nginx_site + function_check nginx_disable_sniffing + nginx_disable_sniffing $EDITH_DOMAIN_NAME + echo '' >> $edith_nginx_site + echo ' access_log /dev/null;' >> $edith_nginx_site + echo ' error_log /dev/null;' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo " root /var/www/$EDITH_DOMAIN_NAME/htdocs;" >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' index index.php;' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # PHP' >> $edith_nginx_site + echo ' location ~ \.php {' >> $edith_nginx_site + echo ' include snippets/fastcgi-php.conf;' >> $edith_nginx_site + echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $edith_nginx_site + echo ' fastcgi_read_timeout 30;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # Location' >> $edith_nginx_site + echo ' location / {' >> $edith_nginx_site + function_check nginx_limits + nginx_limits $EDITH_DOMAIN_NAME '15m' + echo ' try_files $uri $uri/ @edith;' >> $edith_nginx_site + echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site + echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '' >> $edith_nginx_site + echo ' # Restrict access that is unnecessary anyway' >> $edith_nginx_site + echo ' location ~ /\.(ht|git) {' >> $edith_nginx_site + echo ' deny all;' >> $edith_nginx_site + echo ' }' >> $edith_nginx_site + echo '}' >> $edith_nginx_site + + function_check configure_php + configure_php + + function_check create_site_certificate + create_site_certificate $EDITH_DOMAIN_NAME 'yes' + + # create a password for users + if [ ! -f /etc/nginx/.edithpasswd ]; then + touch /etc/nginx/.edithpasswd + fi + if grep -q "$MY_USERNAME:" /etc/nginx/.edithpasswd; then + sed -i "/$MY_USERNAME:/d" /etc/nginx/.edithpasswd + fi + echo -n "$EDITH_PASSWORD" | htpasswd -i -s -c /etc/nginx/.edithpasswd $MY_USERNAME + if [ ! -f /etc/nginx/.edithpasswd ]; then + echo $'/etc/nginx/.edithpasswd not found' + exit 6537683563 + fi + + ${PROJECT_NAME}-pass -u $MY_USERNAME -a edith -p "$EDITH_PASSWORD" + + cp /var/www/$EDITH_DOMAIN_NAME/htdocs/htaccess.example /var/www/$EDITH_DOMAIN_NAME/htdocs/.htaccess + cd /var/www/$EDITH_DOMAIN_NAME/htdocs + npm install -g coffee-script uglify-js + cake build + if [ ! "$?" = "0" ]; then + echo $'Unable to build Edith' + exit 7396483635 + fi + cp config.example.php config.php + if [[ $ONION_ONLY == "no" ]]; then + sed -i "s|define('EDITH_URI'.*|define('EDITH_URI', 'https://$EDITH_DOMAIN_NAME');|g" config.php + else + sed -i "s|define('EDITH_URI'.*|define('EDITH_URI', 'http://$EDITH_ONION_HOSTNAME');|g" config.php + fi + + set_completion_param "edith domain" "$EDITH_DOMAIN_NAME" + chown -R www-data:www-data /var/www/$EDITH_DOMAIN_NAME/htdocs + chmod a+w /var/www/$EDITH_DOMAIN_NAME/htdocs/data + nginx_ensite $EDITH_DAEMON_NAME + systemctl restart nginx + + APP_INSTALLED=1 +} + +function install_interactive_edith { + if [ ! $ONION_ONLY ]; then + ONION_ONLY='no' + fi + + if [[ $ONION_ONLY != "no" ]]; then + GHOST_DOMAIN_NAME='edith.local' + write_config_param "EDITH_DOMAIN_NAME" "$EDITH_DOMAIN_NAME" + else + function_check interactive_site_details + interactive_site_details "edith" "EDITH_DOMAIN_NAME" "EDITH_CODE" + fi + APP_INSTALLED=1 +} + +# NOTE: deliberately no exit 0 From 4f85a93b32e0dd49ce7bbb608ff266061cc57707 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 11:49:25 +0000 Subject: [PATCH 02/14] No hyphen --- src/freedombone-app-edith | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 3f9c9ed2..4ae7233d 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -405,7 +405,7 @@ function install_edith { cp /var/www/$EDITH_DOMAIN_NAME/htdocs/htaccess.example /var/www/$EDITH_DOMAIN_NAME/htdocs/.htaccess cd /var/www/$EDITH_DOMAIN_NAME/htdocs - npm install -g coffee-script uglify-js + npm install -g coffeescript uglify-js cake build if [ ! "$?" = "0" ]; then echo $'Unable to build Edith' From 1fbe08647a3849bb7f37b6817fbbe55a775e08ac Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 11:53:10 +0000 Subject: [PATCH 03/14] Ensure that clone happens --- src/freedombone-app-edith | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 4ae7233d..e897c96e 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -262,25 +262,19 @@ function install_edith { EDITH_ONION_HOSTNAME=$(add_onion_service edith 80 ${EDITH_ONION_PORT}) - if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then - mkdir -p /var/www/$EDITH_DOMAIN_NAME/htdocs + if [ -d /repos/edith ]; then + mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs + cp -r -p /repos/edith/. /var/www/$EDITH_DOMAIN_NAME/htdocs + cd /var/www/$EDITH_DOMAIN_NAME/htdocs + git pull + else + function_check git_clone + git_clone $EDITH_REPO /var/www/$EDITH_DOMAIN_NAME/htdocs fi + if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then - - if [ -d /repos/edith ]; then - mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs - cp -r -p /repos/edith/. /var/www/$EDITH_DOMAIN_NAME/htdocs - cd /var/www/$EDITH_DOMAIN_NAME/htdocs - git pull - else - function_check git_clone - git_clone $EDITH_REPO /var/www/$EDITH_DOMAIN_NAME/htdocs - fi - - if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then - echo $'Unable to clone edith repo' - exit 537593569 - fi + echo $'Unable to clone edith repo' + exit 537593569 fi cd /var/www/$EDITH_DOMAIN_NAME/htdocs From 1c063ee4df501293ec673c669b2efe3840faf7fc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 11:55:10 +0000 Subject: [PATCH 04/14] Remove directory if it exists --- src/freedombone-app-edith | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index e897c96e..a9293fe8 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -262,6 +262,10 @@ function install_edith { EDITH_ONION_HOSTNAME=$(add_onion_service edith 80 ${EDITH_ONION_PORT}) + if [ -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then + rm -rf /var/www/$EDITH_DOMAIN_NAME/htdocs + fi + if [ -d /repos/edith ]; then mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs cp -r -p /repos/edith/. /var/www/$EDITH_DOMAIN_NAME/htdocs From a8165e801d1618a234cd66c2cd03fdc287e5c9c3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 12:21:59 +0000 Subject: [PATCH 05/14] Extra removal code for edith --- src/freedombone-app-edith | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index a9293fe8..990de143 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -243,6 +243,12 @@ function remove_edith { function_check remove_nodejs remove_nodejs edith + + remove_certs $EDITH_DOMAIN_NAME + remove_app edith + + function_check remove_ddns_domain + remove_ddns_domain $EDITH_DOMAIN_NAME } function install_edith { From 346dfbb0cc1cdb821b1c4e352895c17943dbb095 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 12:27:42 +0000 Subject: [PATCH 06/14] Create onion site later --- src/freedombone-app-edith | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 990de143..72d58c17 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -266,7 +266,6 @@ function install_edith { fi fi - EDITH_ONION_HOSTNAME=$(add_onion_service edith 80 ${EDITH_ONION_PORT}) if [ -d /var/www/$EDITH_DOMAIN_NAME/htdocs ]; then rm -rf /var/www/$EDITH_DOMAIN_NAME/htdocs @@ -292,9 +291,11 @@ function install_edith { set_completion_param "edith commit" "$EDITH_COMMIT" if [ ! -d /var/www/$EDITH_DOMAIN_NAME/htdocs/data ]; then - mkdir /var/www/$EDITH_DOMAIN_NAME/htdocs/data + mkdir -p /var/www/$EDITH_DOMAIN_NAME/htdocs/data fi + EDITH_ONION_HOSTNAME=$(add_onion_service edith 80 ${EDITH_ONION_PORT}) + edith_nginx_site=/etc/nginx/sites-available/$EDITH_DOMAIN_NAME if [[ $ONION_ONLY == "no" ]]; then function_check nginx_http_redirect @@ -423,6 +424,7 @@ function install_edith { fi set_completion_param "edith domain" "$EDITH_DOMAIN_NAME" + set_completion_param "edith onion domain" "$EDITH_ONION_HOSTNAME" chown -R www-data:www-data /var/www/$EDITH_DOMAIN_NAME/htdocs chmod a+w /var/www/$EDITH_DOMAIN_NAME/htdocs/data nginx_ensite $EDITH_DAEMON_NAME From 3536b50552c3ac66f464a2d7d524232707ba2f44 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 12:55:11 +0000 Subject: [PATCH 07/14] Remove the hidden service version line when removing onion addresses --- src/freedombone-utils-onion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index 0bd4953b..7f141875 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -83,8 +83,8 @@ function remove_onion_service { if [ ${#nick} -gt 0 ]; then sed -i "/stealth ${nick}/d" /etc/tor/torrc fi - sed -i "/hidden_service_${onion_service_name}/d" /etc/tor/torrc - sed -i "/hidden_service_${onion_service_name}_mobile/d" /etc/tor/torrc + sed -i "/hidden_service_${onion_service_name}/,+1 d" /etc/tor/torrc + sed -i "/hidden_service_${onion_service_name}_mobile/,+1 d" /etc/tor/torrc sed -i "/127.0.0.1:${onion_service_port_to}/d" /etc/tor/torrc if [ $3 ]; then sed -i "/127.0.0.1:${3}/d" /etc/tor/torrc From ea38e19368852178ff118fbc66fe9868f07e0be1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 13:09:20 +0000 Subject: [PATCH 08/14] Change try files --- src/freedombone-app-edith | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 72d58c17..572b6d5b 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -335,7 +335,7 @@ function install_edith { echo ' location / {' >> $edith_nginx_site function_check nginx_limits nginx_limits $EDITH_DOMAIN_NAME '15m' - echo ' try_files $uri $uri/ @edith;' >> $edith_nginx_site + echo ' try_files $uri $uri/ /index.php?$args;' >> $edith_nginx_site echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site @@ -376,7 +376,7 @@ function install_edith { echo ' location / {' >> $edith_nginx_site function_check nginx_limits nginx_limits $EDITH_DOMAIN_NAME '15m' - echo ' try_files $uri $uri/ @edith;' >> $edith_nginx_site + echo ' try_files $uri $uri/ /index.php?$args;' >> $edith_nginx_site echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site From 98701b259c6b717303dd1e870d52934362fc4ecd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 13:10:22 +0000 Subject: [PATCH 09/14] Remove restricts --- src/freedombone-app-edith | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 572b6d5b..2325fa98 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -339,11 +339,6 @@ function install_edith { echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site - echo '' >> $edith_nginx_site - echo ' # Restrict access that is unnecessary anyway' >> $edith_nginx_site - echo ' location ~ /\.(ht|git) {' >> $edith_nginx_site - echo ' deny all;' >> $edith_nginx_site - echo ' }' >> $edith_nginx_site echo '}' >> $edith_nginx_site else echo -n '' > $edith_nginx_site @@ -380,11 +375,6 @@ function install_edith { echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site - echo '' >> $edith_nginx_site - echo ' # Restrict access that is unnecessary anyway' >> $edith_nginx_site - echo ' location ~ /\.(ht|git) {' >> $edith_nginx_site - echo ' deny all;' >> $edith_nginx_site - echo ' }' >> $edith_nginx_site echo '}' >> $edith_nginx_site function_check configure_php From 84476be49b9bdafc7b337410af5f0ae316257cea Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 13:29:46 +0000 Subject: [PATCH 10/14] Default to login with edith notes --- src/freedombone-app-edith | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/freedombone-app-edith b/src/freedombone-app-edith index 2325fa98..9f26dfc8 100755 --- a/src/freedombone-app-edith +++ b/src/freedombone-app-edith @@ -336,8 +336,8 @@ function install_edith { function_check nginx_limits nginx_limits $EDITH_DOMAIN_NAME '15m' echo ' try_files $uri $uri/ /index.php?$args;' >> $edith_nginx_site - echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site - echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site + echo " auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site + echo ' auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site echo '}' >> $edith_nginx_site else @@ -372,8 +372,8 @@ function install_edith { function_check nginx_limits nginx_limits $EDITH_DOMAIN_NAME '15m' echo ' try_files $uri $uri/ /index.php?$args;' >> $edith_nginx_site - echo " #auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site - echo ' #auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site + echo " auth_basic \"${EDITH_LOGIN_TEXT}\";" >> $edith_nginx_site + echo ' auth_basic_user_file /etc/nginx/.edithpasswd;' >> $edith_nginx_site echo ' }' >> $edith_nginx_site echo '}' >> $edith_nginx_site From 53e728fe78295dc76bb61f327809ba6d0eacb33a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 13:32:40 +0000 Subject: [PATCH 11/14] Include edith repo in images --- src/freedombone-image-customise | 1 + 1 file changed, 1 insertion(+) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 71c1e02c..9611b450 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -1945,6 +1945,7 @@ function image_preinstall_repos { git clone $KEYSERVER_WEB_REPO $rootdir/repos/keyserverweb git clone $PEERTUBE_REPO $rootdir/repos/peertube git clone $PRIVATEBIN_REPO $rootdir/repos/privatebin + git clone $EDITH_REPO $rootdir/repos/edith #git clone $WEKAN_REPO $rootdir/repos/wekan #git clone $FLOW_ROUTER_REPO $rootdir/repos/flowrouter #git clone $METEOR_USERACCOUNTS_REPO $rootdir/repos/meteoruseraccounts From 201a907a8791422f1ab3f60dcc3ab87cc23a10b4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 13:40:06 +0000 Subject: [PATCH 12/14] Registered editors --- src/freedombone-app-emacs | 2 +- src/freedombone-app-vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freedombone-app-emacs b/src/freedombone-app-emacs index db73be22..8447b1b8 100755 --- a/src/freedombone-app-emacs +++ b/src/freedombone-app-emacs @@ -188,7 +188,7 @@ function remove_emacs { function install_emacs { apt-get -yq install emacs ispell ibritish ifrench ispanish iitalian irussian iswedish inorwegian iirish ingerman iswiss iogerman idutch idanish ibrazilian ibulgarian ipolish iczech iestonian ilithuanian iukrainian icatalan - update-alternatives --set editor /usr/bin/emacs + update-alternatives --set editor /usr/bin/emacs24 # A minimal emacs configuration #echo -n "(add-to-list 'load-path " > /home/$MY_USERNAME/.emacs diff --git a/src/freedombone-app-vim b/src/freedombone-app-vim index d1544410..0834826f 100755 --- a/src/freedombone-app-vim +++ b/src/freedombone-app-vim @@ -232,7 +232,7 @@ function remove_vim { function install_vim { apt-get -yq install vim - update-alternatives --set editor /usr/bin/vim + update-alternatives --set editor /usr/bin/vim.tiny # add a mutt entry to use Vim to compose emails if [ -f /etc/Muttrc ]; then From c6ce6011877e28fafa0268e9994d518954c8bfa5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 14:55:44 +0000 Subject: [PATCH 13/14] Documentation for edith app --- doc/EN/app_edith.org | 31 ++++ doc/EN/apps.org | 4 + website/EN/app_edith.html | 301 ++++++++++++++++++++++++++++++++++++++ website/EN/apps.html | 254 +++++++++++++++++--------------- 4 files changed, 469 insertions(+), 121 deletions(-) create mode 100644 doc/EN/app_edith.org create mode 100644 website/EN/app_edith.html diff --git a/doc/EN/app_edith.org b/doc/EN/app_edith.org new file mode 100644 index 00000000..e1db5fdf --- /dev/null +++ b/doc/EN/app_edith.org @@ -0,0 +1,31 @@ +#+TITLE: +#+AUTHOR: Bob Mottram +#+EMAIL: bob@freedombone.net +#+KEYWORDS: freedombone, edith, notes +#+DESCRIPTION: How to use Edith notes +#+OPTIONS: ^:nil toc:nil +#+HTML_HEAD: + +#+BEGIN_CENTER +[[file:images/logo.png]] +#+END_CENTER + +#+BEGIN_EXPORT html +
+

Edith Notes

+
+#+END_EXPORT + +Edith notes is the simplest and quickest kind of notes system. It has no complicated user interface. Just enter your domain and a title and a note will be created. Everything typed is saved automatically. + +The speed and minimalism of this type of notes system may make it suitable for things like shopping lists or distraction free writing. + +ssh into the system with: + +#+BEGIN_SRC bash +ssh myusername@mydomain.com -p 2222 +#+END_SRC + +Select *Administrator controls* then *App Settings* then *edith*. Enter a subdomain name, such as /notes.mydomain.com/, and optionally a freedns code. When the installation is complete you can then look up the password for the site within the *Passwords* section of the *Administrator control panel*, then navigate to the subdomain. Log in, then enter something like /notes.mydomain.com/testnote/ and start typing. + +It is possible to turn off the login via *App Settings/edith* if you wish, but this will enable anyone on the internet to view or edit notes on your system, which could have obvious privacy or stability implications. From *App settings/edith* it's also possible to browse through your notes files. diff --git a/doc/EN/apps.org b/doc/EN/apps.org index b1d1f42e..94023f09 100644 --- a/doc/EN/apps.org +++ b/doc/EN/apps.org @@ -41,6 +41,10 @@ Enables you to use the system as a music server which any DLNA compatible device A databaseless wiki system. [[./app_dokuwiki.html][How to use it]] +* Edith +Extremely simple and distraction-free notes system. + +[[./app_edith.html][How to use it]] * Emacs If you use the Mutt client to read your email then this will set it up to use emacs for composing new mail. diff --git a/website/EN/app_edith.html b/website/EN/app_edith.html new file mode 100644 index 00000000..07f505dc --- /dev/null +++ b/website/EN/app_edith.html @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+

logo.png +

+
+
+ +
+

Edith Notes

+
+ +

+Edith notes is the simplest and quickest kind of notes system. It has no complicated user interface. Just enter your domain and a title and a note will be created. Everything typed is saved automatically. +

+ +

+The speed and minimalism of this type of notes system may make it suitable for things like shopping lists or distraction free writing. +

+ +

+ssh into the system with: +

+ +
+
ssh myusername@mydomain.com -p 2222
+
+
+ +

+Select Administrator controls then App Settings then edith. Enter a subdomain name, such as notes.mydomain.com, and optionally a freedns code. When the installation is complete you can then look up the password for the site within the Passwords section of the Administrator control panel, then navigate to the subdomain. Log in, then enter something like notes.mydomain.com/testnote and start typing. +

+ +

+It is possible to turn off the login via App Settings/edith if you wish, but this will enable anyone on the internet to view or edit notes on your system, which could have obvious privacy or stability implications. From App settings/edith it's also possible to browse through your notes files. +

+
+
+ + + + +
+ + diff --git a/website/EN/apps.html b/website/EN/apps.html index 5eea8214..9d247faa 100644 --- a/website/EN/apps.html +++ b/website/EN/apps.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -265,9 +265,9 @@ The base install of the system just contains an email server and Mutt client, bu -
-

Akaunting

-
+
+

Akaunting

+

A web based accounts system for small businesses or freelancers.

@@ -277,9 +277,9 @@ A web based accounts system for small businesses or freelancers.

-
-

CryptPad

-
+
+

CryptPad

+

Collaborate on editing documents, presentations and source code, or vote on things. All with a good level of security.

@@ -289,9 +289,9 @@ Collaborate on editing documents, presentations and source code, or vote on thin

-
-

DLNA

-
+
+

DLNA

+

Enables you to use the system as a music server which any DLNA compatible devices can connect to within your home network.

@@ -301,9 +301,9 @@ Enables you to use the system as a music server which any DLNA compatible device

-
-

Dokuwiki

-
+
+

Dokuwiki

+

A databaseless wiki system.

@@ -313,9 +313,21 @@ A databaseless wiki system.

-
-

Emacs

-
+
+

Edith

+
+

+Extremely simple and distraction-free notes system. +

+ +

+How to use it +

+
+
+
+

Emacs

+

If you use the Mutt client to read your email then this will set it up to use emacs for composing new mail.

@@ -325,9 +337,9 @@ If you use the Mutt client to read your email then this will set it up to use em

-
-

Etherpad

-
+
+

Etherpad

+

Collaborate on creating documents in real time. Maybe you're planning a holiday with other family members or creating documentation for a Free Software project along with other volunteers. Etherpad is hard to beat for simplicity and speed. Only users of the system will be able to access it.

@@ -337,9 +349,9 @@ Collaborate on creating documents in real time. Maybe you're planning a holiday

-
-

Federated wiki

-
+
+

Federated wiki

+

A new approach to creating wiki content.

@@ -349,9 +361,9 @@ A new approach to creating wiki content.

-
-

Friendica

-
+
+

Friendica

+

Federated social network system.

@@ -361,9 +373,9 @@ Federated social network system.

-
-

Ghost

-
+
+

Ghost

+

Modern looking blogging system.

@@ -373,9 +385,9 @@ Modern looking blogging system.

-
-

GNU Social

-
+
+

GNU Social

+

Federated social network based on the OStatus protocol. You can "remote follow" other users within the GNU Social federation.

@@ -385,9 +397,9 @@ Federated social network based on the OStatus protocol. You can "remote follo

-
-

Gogs

-
+
+

Gogs

+

Lightweight git project hosting system. You can mirror projects from Github, or if Github turns evil then just host your own projects while retaining the familiar fork-and-pull workflow. If you can use Github then you can also use Gogs.

@@ -397,9 +409,9 @@ Lightweight git project hosting system. You can mirror projects from Github, or

-
-

HTMLy

-
+
+

HTMLy

+

Databaseless blogging system. Quite simple and with a markdown-like format.

@@ -409,9 +421,9 @@ Databaseless blogging system. Quite simple and with a markdown-like format.

-
-

Hubzilla

-
+
+

Hubzilla

+

Web publishing platform with social network like features and good privacy controls so that it's possible to specify who can see which content. Includes photo albums, calendar, wiki and file storage.

@@ -421,9 +433,9 @@ Web publishing platform with social network like features and good privacy contr

-
-

Icecast media stream

-
+
+

Icecast media stream

+

Make your own internet radio station.

@@ -433,9 +445,9 @@ Make your own internet radio station.

-
-

IRC Server (ngirc)

-
+
+

IRC Server (ngirc)

+

Run your own IRC chat channel which can be secured with a password and accessible via an onion address. A bouncer is included so that you can receive messages sent while you were offline. Works with Hexchat and other popular clients.

@@ -445,18 +457,18 @@ Run your own IRC chat channel which can be secured with a password and accessibl

-
-

Jitsi Meet

-
+
+

Jitsi Meet

+

Experimental WebRTC video conferencing system, similar to Google Hangouts. This may not be fully functional, but is hoped to be in the near future.

-
-

KanBoard

-
+
+

KanBoard

+

A simple kanban system for managing projects or TODO lists.

@@ -466,9 +478,9 @@ A simple kanban system for managing projects or TODO lists.

-
-

Key Server

-
+
+

Key Server

+

An OpenPGP key server for storing and retrieving GPG public keys.

@@ -478,9 +490,9 @@ An OpenPGP key server for storing and retrieving GPG public keys.

-
-

Koel

-
+
+

Koel

+

Access your music collection from any internet connected device.

@@ -490,9 +502,9 @@ Access your music collection from any internet connected device.

-
-

Lychee

-
+
+

Lychee

+

Make your photo albums available on the web.

@@ -502,9 +514,9 @@ Make your photo albums available on the web.

-
-

Mailpile

-
+
+

Mailpile

+

Modern email client which supports GPG encryption.

@@ -514,9 +526,9 @@ Modern email client which supports GPG encryption.

-
-

Matrix

-
+
+

Matrix

+

Multi-user chat with some security and moderation controls.

@@ -526,9 +538,9 @@ Multi-user chat with some security and moderation controls.

-
-

Mediagoblin

-
+
+

Mediagoblin

+

Publicly host video and audio files so that you don't need to use YouTube/Vimeo/etc.

@@ -538,9 +550,9 @@ Publicly host video and audio files so that you don't need to use YouTube/Vimeo/

-
-

Mumble

-
+
+

Mumble

+

The popular VoIP and text chat system. Say goodbye to old-fashioned telephony conferences with silly dial codes. Also works well on mobile.

@@ -550,9 +562,9 @@ The popular VoIP and text chat system. Say goodbye to old-fashioned telephony co

-
-

NextCloud

-
+
+

NextCloud

+

Store files on your server and sync them with laptops or mobile devices. Includes many plugins including videoconferencing and collaborative document editing.

@@ -562,9 +574,9 @@ Store files on your server and sync them with laptops or mobile devices. Include

-
-

PeerTube

-
+
+

PeerTube

+

Peer-to-peer video hosting. Similar to Mediagoblin, but the P2P aspect better enables the streaming load to be shared across servers.

@@ -574,9 +586,9 @@ Peer-to-peer video hosting. Similar to Mediagoblin, but the P2P aspect better en

-
-

PI-Hole

-
+
+

PI-Hole

+

The black hole for web adverts. Block adverts at the domain name level within your local network. It can significantly reduce bandwidth, speed up page load times and protect your systems from being tracked by spyware.

@@ -586,9 +598,9 @@ The black hole for web adverts. Block adverts at the domain name level within yo

-
-

PostActiv

-
+
+

PostActiv

+

An alternative federated social networking system compatible with GNU Social, Pleroma and Mastodon. It includes some optimisations and fixes currently not available within the main GNU Social project.

@@ -598,9 +610,9 @@ An alternative federated social networking system compatible with GNU Social, Pl

-
-

PrivateBin

-
+
+

PrivateBin

+

A pastebin where the server has zero knowledge of the content being pasted.

@@ -610,9 +622,9 @@ A pastebin where the server has zero knowledge of the content being pasted.

-
-

Profanity

-
+
+

Profanity

+

A shell based XMPP client which you can run on the Freedombone server via ssh.

@@ -622,9 +634,9 @@ A shell based XMPP client which you can run on the Freedombone server via ssh.

-
-

Riot Web

-
+
+

Riot Web

+

A browser based user interface for the Matrix federated communications system, including WebRTC audio and video chat.

@@ -634,9 +646,9 @@ A browser based user interface for the Matrix federated communications system, i

-
-

SearX

-
+
+

SearX

+

A metasearch engine for customised and private web searches.

@@ -646,9 +658,9 @@ A metasearch engine for customised and private web searches.

-
-

tt-rss

-
+
+

tt-rss

+

Private RSS reader. Pulls in RSS/Atom feeds via Tor and is only accessible via an onion address. Have "the right to read" without the Surveillance State knowing what you're reading. Also available with a user interface suitable for viewing on mobile devices via a browser such as OrFox.

@@ -658,9 +670,9 @@ Private RSS reader. Pulls in RSS/Atom feeds via Tor and is only accessible via a

-
-

Syncthing

-
+
+

Syncthing

+

Possibly the best way to synchronise files across all of your devices. Once it has been set up it "just works" with no user intervention needed.

@@ -670,9 +682,9 @@ Possibly the best way to synchronise files across all of your devices. Once it h

-
-

Tahoe-LAFS

-
+
+

Tahoe-LAFS

+

Robust and encrypted storage of files on one or more server.

@@ -682,9 +694,9 @@ Robust and encrypted storage of files on one or more server.

-
-

Tox

-
+
+

Tox

+

Client and bootstrap node for the Tox chat/VoIP system.

@@ -694,9 +706,9 @@ Client and bootstrap node for the Tox chat/VoIP system.

-
-

Turtl

-
+
+

Turtl

+

A system for privately creating and sharing notes and images, similar to Evernote but without the spying.

@@ -706,18 +718,18 @@ A system for privately creating and sharing notes and images, similar to Evernot

-
-

Vim

-
+
+

Vim

+

If you use the Mutt client to read your email then this will set it up to use vim for composing new mail.

-
-

Virtual Private Network (VPN)

-
+
+

Virtual Private Network (VPN)

+

Set up a VPN on your server so that you can bypass local internet censorship.

@@ -727,9 +739,9 @@ Set up a VPN on your server so that you can bypass local internet censorship.

-
-

XMPP

-
+
+

XMPP

+

Chat server which can be used together with client such as Gajim or Conversations to provide end-to-end content security and also onion routed metadata security. Includes advanced features such as client state notification to save battery power on your mobile devices, support for seamless roaming between networks and message carbons so that you can receive the same messages while being simultaneously logged in to your account on more than one device.

From 642ddc47f91b46988e8299b84f940b0dc918efe8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Feb 2018 15:08:33 +0000 Subject: [PATCH 14/14] More width on password entry to show longer onion address --- src/freedombone-controlpanel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index f6a616b2..3094551f 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -289,7 +289,7 @@ function view_or_change_passwords { trap "rm -f $data" 0 1 2 5 15 dialog --title "$titlestr" \ --backtitle $"Freedombone Control Panel" \ - --inputbox "$viewstr" 12 60 "$CURR_PASSWORD" 2>$data + --inputbox "$viewstr" 12 75 "$CURR_PASSWORD" 2>$data sel=$? case $sel in 0)