From 8c20b15f6f9d5a7b2184a3cf28c1720055584208 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 23 Jun 2017 10:35:58 +0100 Subject: [PATCH] Experimental control scripts --- Makefile | 5 +++- src/freedombone-adduser | 4 +-- src/freedombone-app-ghost | 3 +++ src/freedombone-controlpanel | 17 +++++++----- src/freedombone-controlpanel-user | 4 +++ src/freedombone-prepare-scripts | 43 +++++++++++++++++++++++++++++++ src/freedombone-utils-final | 4 +-- src/freedombone-utils-web | 4 +-- 8 files changed, 71 insertions(+), 13 deletions(-) create mode 100755 src/freedombone-prepare-scripts diff --git a/Makefile b/Makefile index 91c39be2..1cbb5783 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ install: cp img/backgrounds/${APP}_*.png ${DESTDIR}${PREFIX}/share cp img/avatars/* ${DESTDIR}/usr/share/${APP}/avatars cp src/* ${DESTDIR}${PREFIX}/bin - cp src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control +# cp src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control cp src/${APP}-mesh-batman ${DESTDIR}${PREFIX}/bin/batman cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup2friends @@ -46,6 +46,7 @@ install: chown -R root: /usr/share/${APP} chmod -R +r /usr/share/${APP} # bash -c "./translate install" + /usr/local/bin/${APP}-prepare-scripts uninstall: rm -f ${PREFIX}/share/${APP}_*.png rm -f ${PREFIX}/share/man/man1/backup.1.gz @@ -61,6 +62,8 @@ uninstall: rm -f ${PREFIX}/bin/restorefromfriend rm -f ${PREFIX}/bin/batman rm -rf /etc/${APP} + rm -f ${PREFIX}/bin/control + rm -f ${PREFIX}/bin/controluser bash -c "./translate uninstall" clean: rm -f \#* \.#* debian/*.substvars debian/*.log src/*~ diff --git a/src/freedombone-adduser b/src/freedombone-adduser index 59524152..c9611562 100755 --- a/src/freedombone-adduser +++ b/src/freedombone-adduser @@ -235,8 +235,8 @@ if [ -f /etc/nginx/.htpasswd ]; then fi # add user menu on ssh login -if ! grep -q 'control' /home/$ADD_USERNAME/.bashrc; then - echo 'control' >> /home/$ADD_USERNAME/.bashrc +if ! grep -q 'controluser' /home/$ADD_USERNAME/.bashrc; then + echo 'controluser' >> /home/$ADD_USERNAME/.bashrc fi ${PROJECT_NAME}-pass -u $ADD_USERNAME -a login -p "$NEW_USER_PASSWORD" diff --git a/src/freedombone-app-ghost b/src/freedombone-app-ghost index 54c09a52..3367ae3c 100755 --- a/src/freedombone-app-ghost +++ b/src/freedombone-app-ghost @@ -322,6 +322,9 @@ function remove_ghost { function ghost_create_config { ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js + function_check get_mariadb_password + get_mariadb_password + echo "var path = require('path')," > $ghost_config echo ' config;' >> $ghost_config echo '' >> $ghost_config diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index 90d0cc75..0eef20e6 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -33,6 +33,13 @@ PROJECT_NAME='freedombone' export TEXTDOMAIN=${PROJECT_NAME}-controlpanel export TEXTDOMAINDIR="/usr/share/locale" +if [[ $USER != 'root' ]]; then + # show the user version of the control panel + #${PROJECT_NAME}-controlpanel-user + controluser + exit 0 +fi + function please_wait { local str width height length @@ -49,6 +56,8 @@ function please_wait { please_wait +# Start including files + source /usr/local/bin/${PROJECT_NAME}-vars UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* @@ -63,6 +72,8 @@ do source $f done +# End including files + COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt SELECTED_USERNAME= SIP_CONFIGURATION_FILE=/etc/sipwitch.conf @@ -2146,12 +2157,6 @@ function menu_top_level { done } -if [[ $USER != 'root' ]]; then - # show the user version of the control panel - ${PROJECT_NAME}-controlpanel-user - exit 0 -fi - if [ ! -f $COMPLETION_FILE ]; then echo $'This command should only be run on an installed Freedombone system' exit 1 diff --git a/src/freedombone-controlpanel-user b/src/freedombone-controlpanel-user index c13ecb2d..a009902d 100755 --- a/src/freedombone-controlpanel-user +++ b/src/freedombone-controlpanel-user @@ -37,6 +37,8 @@ MY_EMAIL_ADDRESS=$USER@$HOSTNAME GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//') +# Start including files + UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* for f in $UTILS_FILES do @@ -49,6 +51,8 @@ do source $f done +# End including files + function any_key { echo ' ' read -n1 -r -p $"Press any key to continue..." key diff --git a/src/freedombone-prepare-scripts b/src/freedombone-prepare-scripts new file mode 100755 index 00000000..6edc099d --- /dev/null +++ b/src/freedombone-prepare-scripts @@ -0,0 +1,43 @@ +#!/bin/bash +# +# .---. . . +# | | | +# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. +# | | (.-' (.-' ( | ( )| | | | )( )| | (.-' +# ' ' --' --' -' - -' ' ' -' -' -' ' - --' +# +# Freedom in the Cloud +# +# Prepares control scripts +# +# License +# ======= +# +# Copyright (C) 2017 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 . + +PROJECT_NAME='freedombone' + +cat /usr/local/bin/${PROJECT_NAME}-vars /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* > /tmp/includescripts + +cat /tmp/includescripts /usr/local/bin/freedombone-controlpanel > /usr/local/bin/control +cat /tmp/includescripts /usr/local/bin/freedombone-controlpanel-user > /usr/local/bin/controluser + +sed '/# Start including files/,/# End including files/d' /usr/local/bin/control +sed '/# Start including files/,/# End including files/d' /usr/local/bin/controluser + +rm /tmp/includescripts + +exit 0 diff --git a/src/freedombone-utils-final b/src/freedombone-utils-final index 085c3184..0dedf637 100755 --- a/src/freedombone-utils-final +++ b/src/freedombone-utils-final @@ -63,8 +63,8 @@ $(get_ssh_server_key) echo '' # add user menu on ssh login - if ! grep -q 'control' /home/$MY_USERNAME/.bashrc; then - echo 'control' >> /home/$MY_USERNAME/.bashrc + if ! grep -q 'controluser' /home/$MY_USERNAME/.bashrc; then + echo 'controluser' >> /home/$MY_USERNAME/.bashrc fi if [ ! -f $IMAGE_PASSWORD_FILE ]; then if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then diff --git a/src/freedombone-utils-web b/src/freedombone-utils-web index 432a3334..41ce72a9 100755 --- a/src/freedombone-utils-web +++ b/src/freedombone-utils-web @@ -515,10 +515,10 @@ function install_command_line_browser { # set the home page if ! grep -q "WWW_HOME" /home/$MY_USERNAME/.bashrc; then - if ! grep -q 'control' /home/$MY_USERNAME/.bashrc; then + if ! grep -q 'controluser' /home/$MY_USERNAME/.bashrc; then echo "export WWW_HOME=$DEFAULT_SEARCH" >> /home/$MY_USERNAME/.bashrc else - sed -i "/control/i export WWW_HOME=$DEFAULT_SEARCH" /home/$MY_USERNAME/.bashrc + sed -i "/controluser/i export WWW_HOME=$DEFAULT_SEARCH" /home/$MY_USERNAME/.bashrc fi fi