freedombone-controlpanel 74KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Administrator control panel for the Freedombone system
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2015-2017 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. PROJECT_NAME='freedombone'
  31. export TEXTDOMAIN=${PROJECT_NAME}-controlpanel
  32. export TEXTDOMAINDIR="/usr/share/locale"
  33. if [[ $USER != 'root' ]]; then
  34. # show the user version of the control panel
  35. #${PROJECT_NAME}-controlpanel-user
  36. controluser
  37. exit 0
  38. fi
  39. function please_wait {
  40. local str width height length
  41. width=$(tput cols)
  42. height=$(tput lines)
  43. str=$"Please wait"
  44. length=${#str}
  45. clear
  46. tput cup $((height / 2)) $(((width / 2) - (length / 2)))
  47. echo "$str"
  48. tput cup $((height * 3 / 5)) $(((width / 2)))
  49. echo -n ''
  50. }
  51. please_wait
  52. # Start including files
  53. source /usr/local/bin/${PROJECT_NAME}-vars
  54. UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
  55. for f in $UTILS_FILES
  56. do
  57. source $f
  58. done
  59. APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
  60. for f in $APP_FILES
  61. do
  62. source $f
  63. done
  64. # End including files
  65. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  66. SELECTED_USERNAME=
  67. SIP_CONFIGURATION_FILE=/etc/sipwitch.conf
  68. ADMIN_USER=
  69. UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
  70. UPDATE_DATE_SCRIPT=/usr/bin/updatedate
  71. # Minimum number of characters in a password
  72. MINIMUM_PASSWORD_LENGTH=$(cat /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-passwords | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
  73. # Mumble
  74. MUMBLE_PORT=64738
  75. MUMBLE_ONION_PORT=8095
  76. SSH_PORT=2222
  77. # outgoing SMTP proxy
  78. SMTP_PROXY_ENABLE=$'no'
  79. SMTP_PROXY_PROTOCOL='smtps'
  80. SMTP_PROXY_SERVER='mail.myispdomain'
  81. SMTP_PROXY_PORT=465
  82. SMTP_PROXY_USERNAME=''
  83. SMTP_PROXY_PASSWORD=''
  84. WIFI_INTERFACE=wlan0
  85. WIFI_SSID=
  86. WIFI_TYPE='wpa2-psk'
  87. WIFI_PASSPHRASE=
  88. WIFI_HOTSPOT='no'
  89. WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
  90. USB_DRIVE=sdb
  91. # get default USB from config file
  92. CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
  93. read_config_param WIFI_HOTSPOT
  94. read_config_param WIFI_INTERFACE
  95. read_config_param WIFI_TYPE
  96. read_config_param WIFI_SSID
  97. read_config_param WIFI_PASSPHRASE
  98. read_config_param SSH_PORT
  99. read_config_param SMTP_PROXY_ENABLE
  100. read_config_param SMTP_PROXY_PROTOCOL
  101. read_config_param SMTP_PROXY_SERVER
  102. read_config_param SMTP_PROXY_PORT
  103. read_config_param SMTP_PROXY_USERNAME
  104. read_config_param SMTP_PROXY_PASSWORD
  105. read_config_param USB_DRIVE
  106. read_config_param MY_USERNAME
  107. read_config_param ONION_ONLY
  108. if [[ $USB_DRIVE == *"dev"* ]]; then
  109. USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
  110. fi
  111. function any_key {
  112. echo ''
  113. read -n1 -rsp $"Press any key to continue..." key
  114. }
  115. function any_key_verify {
  116. echo ''
  117. read -n1 -rsp $"Press any key to continue or C to check a hash..." key
  118. if [[ "$key" != 'c' && "$key" != 'C' ]]; then
  119. return
  120. fi
  121. data=$(tempfile 2>/dev/null)
  122. trap "rm -f $data" 0 1 2 5 15
  123. dialog --title $"Check tripwire hash" \
  124. --backtitle $"Freedombone Control Panel" \
  125. --inputbox $"Paste your tripwire hash below and it will be checked against the current database" 12 60 2>$data
  126. sel=$?
  127. case $sel in
  128. 0)
  129. GIVEN_HASH=$(<$data)
  130. if [ ${#GIVEN_HASH} -gt 8 ]; then
  131. if [[ "$GIVEN_HASH" == *' '* ]]; then
  132. dialog --title $"Check tripwire" \
  133. --msgbox $"\nThe hash should not contain any spaces" 10 40
  134. else
  135. DBHASH=$(sha512sum /var/lib/tripwire/${HOSTNAME}.twd | awk -F ' ' '{print $1}')
  136. if [[ "$DBHASH" == "$GIVEN_HASH" ]]; then
  137. dialog --title $"Check tripwire" \
  138. --msgbox $"\nSuccess\n\nThe hash you gave matches the current tripwire database" 10 40
  139. else
  140. dialog --title $"Check tripwire" \
  141. --msgbox $"\nFailed\n\nThe hash you gave does not match the current tripwire database. This might be because you reset the tripwire, or there could have been an unauthorised modification of the system" 12 50
  142. fi
  143. fi
  144. fi
  145. ;;
  146. esac
  147. }
  148. function get_app_icann_address {
  149. app_name="$1"
  150. if grep -q "${app_name} domain" $COMPLETION_FILE; then
  151. echo $(cat ${COMPLETION_FILE} | grep "${app_name} domain" | head -n 1 | awk -F ':' '{print $2}')
  152. return
  153. fi
  154. echo "${DEFAULT_DOMAIN_NAME}"
  155. }
  156. function passwords_select_user {
  157. SELECTED_USERNAME=
  158. users_array=($(ls /home))
  159. delete=(git)
  160. for del in ${delete[@]}
  161. do
  162. users_array=(${users_array[@]/$del})
  163. done
  164. i=0
  165. W=()
  166. name=()
  167. for u in ${users_array[@]}
  168. do
  169. if [[ $(is_valid_user "$u") == "1" ]]; then
  170. i=$((i+1))
  171. W+=($i "$u")
  172. name+=("$u")
  173. fi
  174. done
  175. if [ $i -eq 1 ]; then
  176. SELECTED_USERNAME="${name[0]}"
  177. else
  178. user_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
  179. if [ $? -eq 0 ]; then
  180. SELECTED_USERNAME="${name[$((user_index-1))]}"
  181. fi
  182. fi
  183. }
  184. function passwords_show_apps {
  185. SELECTED_APP=
  186. i=0
  187. W=()
  188. name=()
  189. for a in "${APPS_AVAILABLE[@]}"
  190. do
  191. if [[ $(function_exists change_password_${a}) == "1" ]]; then
  192. i=$((i+1))
  193. W+=($i "$a")
  194. name+=("$a")
  195. fi
  196. done
  197. i=$((i+1))
  198. W+=($i "mariadb")
  199. name+=("mariadb")
  200. selected_app_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select App" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
  201. if [ $? -eq 0 ]; then
  202. SELECTED_APP="${name[$((selected_app_index-1))]}"
  203. fi
  204. }
  205. function reset_password_tries {
  206. passwords_select_user
  207. if [ ! $SELECTED_USERNAME ]; then
  208. return
  209. fi
  210. pam_tally --user $SELECTED_USERNAME --reset
  211. dialog --title $"Reset password tries" \
  212. --msgbox $"Password tries have been reset for $SELECTED_USERNAME" 6 60
  213. }
  214. function view_or_change_passwords {
  215. passwords_select_user
  216. if [ ! $SELECTED_USERNAME ]; then
  217. return
  218. fi
  219. detect_installed_apps
  220. passwords_show_apps
  221. if [ ! $SELECTED_APP ]; then
  222. return
  223. fi
  224. CURR_PASSWORD=$(${PROJECT_NAME}-pass -u ${SELECTED_USERNAME} -a ${SELECTED_APP})
  225. icann_address=$(get_app_icann_address "$app_name")
  226. onion_address=$(get_app_onion_address "${SELECTED_APP}")
  227. titlestr=$"View or Change Password"
  228. if [ ${#onion_address} -gt 0 ]; then
  229. viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address\n\nCopy or change it if you wish."
  230. else
  231. viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address\n\nCopy or change it if you wish."
  232. fi
  233. if [ -f /root/.nostore ]; then
  234. titlestr=$"Change Password"
  235. if [ ${#onion_address} -gt 0 ]; then
  236. viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address."
  237. else
  238. viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address."
  239. fi
  240. fi
  241. if [[ "${SELECTED_APP}" == 'mariadb' ]]; then
  242. CURR_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
  243. dialog --title $"MariaDB database password" \
  244. --msgbox "\n ${CURR_PASSWORD}" 7 40
  245. return
  246. fi
  247. data=$(tempfile 2>/dev/null)
  248. trap "rm -f $data" 0 1 2 5 15
  249. dialog --title "$titlestr" \
  250. --backtitle $"Freedombone Control Panel" \
  251. --inputbox "$viewstr" 12 60 "$CURR_PASSWORD" 2>$data
  252. sel=$?
  253. case $sel in
  254. 0)
  255. CURR_PASSWORD=$(<$data)
  256. if [ ${#CURR_PASSWORD} -gt 8 ]; then
  257. ${PROJECT_NAME}-pass -u ${SELECTED_USERNAME} -a ${SELECTED_APP} -p "${CURR_PASSWORD}"
  258. change_password_${SELECTED_APP} ${SELECTED_USERNAME} "${CURR_PASSWORD}"
  259. dialog --title $"Change password" \
  260. --msgbox $"The password was changed" 6 40
  261. else
  262. dialog --title $"Change password" \
  263. --msgbox $"The password given must be at least 8 characters" 6 40
  264. fi
  265. ;;
  266. esac
  267. }
  268. function check_for_updates {
  269. if [ ! -f /etc/cron.weekly/$UPGRADE_SCRIPT_NAME ]; then
  270. dialog --title $"Check for updates" \
  271. --msgbox $"Upgrade script was not found" 6 40
  272. return
  273. fi
  274. clear
  275. . /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
  276. any_key
  277. }
  278. function add_user {
  279. data=$(tempfile 2>/dev/null)
  280. trap "rm -f $data" 0 1 2 5 15
  281. dialog --backtitle $"Freedombone Control Panel" \
  282. --title $"Add new user" \
  283. --form "\n" 8 60 3 \
  284. $"Username:" 1 1 "" 1 28 16 15 \
  285. $"ssh public key (optional):" 2 1 "" 2 28 40 10000 \
  286. 2> $data
  287. sel=$?
  288. case $sel in
  289. 1) return;;
  290. 255) return;;
  291. esac
  292. new_user_username=$(cat $data | sed -n 1p)
  293. new_user_ssh_public_key=$(cat $data | sed -n 2p)
  294. if [ ${#new_user_username} -lt 2 ]; then
  295. dialog --title $"New username" \
  296. --msgbox $"No username was given" 6 40
  297. return
  298. fi
  299. if [[ "$new_user_username" == *" "* ]]; then
  300. dialog --title $"Invalid username" \
  301. --msgbox $"The username should not contain any spaces" 6 40
  302. return
  303. fi
  304. if [ ${#new_user_ssh_public_key} -lt 20 ]; then
  305. clear
  306. ${PROJECT_NAME}-adduser "$new_user_username"
  307. any_key
  308. else
  309. if [[ "$new_user_ssh_public_key" == "ssh-"* ]]; then
  310. clear
  311. ${PROJECT_NAME}-adduser "$new_user_username" "$new_user_ssh_public_key"
  312. any_key
  313. else
  314. dialog --title $"ssh public key" \
  315. --msgbox $"This does not look like an ssh public key" 6 40
  316. fi
  317. fi
  318. }
  319. function pad_string {
  320. echo -n -e "$1" | sed -e :a -e 's/^.\{1,25\}$/& /;ta'
  321. }
  322. function show_domains {
  323. read_config_param "DEFAULT_DOMAIN_NAME"
  324. echo 'Domains'
  325. echo '======='
  326. echo ''
  327. echo -n -e "$(pad_string 'Name')"
  328. echo -n -e "$(pad_string 'ICANN')"
  329. echo -n -e "$(pad_string 'Tor')"
  330. echo ''
  331. echo '--------------------------------------------------------------------------'
  332. if grep -q "ssh onion domain" $COMPLETION_FILE; then
  333. echo -n -e "$(pad_string 'ssh')"
  334. echo -n -e "$(pad_string ${DEFAULT_DOMAIN_NAME})"
  335. echo "$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')"
  336. fi
  337. if grep -q "email onion domain" $COMPLETION_FILE; then
  338. echo -n -e "$(pad_string 'Email')"
  339. echo -n -e "$(pad_string ${DEFAULT_DOMAIN_NAME})"
  340. echo "$(cat ${COMPLETION_FILE} | grep 'email onion domain' | awk -F ':' '{print $2}')"
  341. fi
  342. if grep -q "sks onion domain" $COMPLETION_FILE; then
  343. read_config_param "KEYSERVER_DOMAIN_NAME"
  344. echo -n -e "$(pad_string 'SKS')"
  345. echo -n -e "$(pad_string ${KEYSERVER_DOMAIN_NAME})"
  346. echo "$(cat ${COMPLETION_FILE} | grep 'sks onion domain' | awk -F ':' '{print $2}')"
  347. fi
  348. for app_name in "${APPS_INSTALLED_NAMES[@]}"
  349. do
  350. if ! grep -q "SHOW_ON_ABOUT=1" /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}; then
  351. continue
  352. fi
  353. # handle the foibles of capitalisation
  354. if ! grep -q "${app_name} domain" $COMPLETION_FILE; then
  355. app_name_upper=$(echo ${app_name} | awk '{print toupper($0)}')
  356. if grep -q "${app_name_upper} domain" $COMPLETION_FILE; then
  357. app_name=${app_name_upper}
  358. else
  359. app_name_first_upper="$(tr '[:lower:]' '[:upper:]' <<< ${app_name:0:1})${app_name:1}"
  360. if grep -q "${app_name_first_upper} domain" $COMPLETION_FILE; then
  361. app_name=${app_name_first_upper}
  362. fi
  363. fi
  364. fi
  365. if [ ${#app_name} -gt 0 ]; then
  366. icann_address=$(get_app_icann_address "$app_name")
  367. if grep -q "SHOW_ICANN_ADDRESS_ON_ABOUT=0" /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}; then
  368. icann_address='-'
  369. fi
  370. if [[ $ONION_ONLY != 'no' ]]; then
  371. if [[ ${icann_address} != ${LOCAL_NAME}.local ]]; then
  372. icann_address='-'
  373. fi
  374. fi
  375. onion_address=$(get_app_onion_address "$app_name")
  376. if [ ${#onion_address} -eq 0 ]; then
  377. onion_address="-"
  378. fi
  379. echo -n -e "$(pad_string "${app_name}")"
  380. echo -n -e "$(pad_string "${icann_address}")"
  381. echo "${onion_address}"
  382. if grep -q "${app_name}_mobile onion domain" $COMPLETION_FILE; then
  383. onion_address=$(get_app_onion_address "${app_name}" "mobile")
  384. echo -n -e "$(pad_string "${app_name} (mobile)")"
  385. echo -n -e "$(pad_string "${icann_address}")"
  386. echo "${onion_address}"
  387. fi
  388. fi
  389. done
  390. if grep -q "rss reader domain" $COMPLETION_FILE; then
  391. if [ -d /var/lib/tor/hidden_service_ttrss ]; then
  392. echo -n -e "$(pad_string 'RSS reader')"
  393. RSSDOM='-'
  394. echo -n -e "$(pad_string ${RSSDOM})"
  395. echo -n "$(cat /var/lib/tor/hidden_service_ttrss/hostname)"
  396. echo ''
  397. fi
  398. if [ -d /var/lib/tor/hidden_service_ttrss_mobile ]; then
  399. echo -n -e "$(pad_string 'RSS mobile')"
  400. RSSMOBILEDOM='-'
  401. echo -n -e "$(pad_string ${RSSMOBILEDOM})"
  402. echo -n "$(cat /var/lib/tor/hidden_service_ttrss_mobile/hostname)"
  403. echo ''
  404. fi
  405. fi
  406. echo ''
  407. }
  408. function show_users {
  409. echo 'Users'
  410. echo '====='
  411. echo ''
  412. echo -n -e "$(pad_string 'Name')"
  413. if [[ $(app_is_installed sip) == "1" ]]; then
  414. echo -n -e "$(pad_string 'SIP ext')"
  415. fi
  416. echo -n -e "$(pad_string 'Data')"
  417. echo ''
  418. echo '----------------------------------'
  419. for d in /home/*/ ; do
  420. USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
  421. if [[ $(is_valid_user "$USRNAME") == "1" ]]; then
  422. echo -n -e "$(pad_string ${USRNAME})"
  423. # get the SIP extension
  424. SIPEXT=
  425. if [ -f $SIP_CONFIGURATION_FILE ]; then
  426. while read ext; do
  427. if [[ $ext == *"user id"* ]]; then
  428. CURR_UID=$(echo "$ext" | awk -F '"' '{print $2}' | awk -F '"' '{print $1}')
  429. fi
  430. if [[ $ext == *"extension"* ]]; then
  431. if [[ $CURR_UID == $USRNAME ]]; then
  432. SIPEXT=$(echo "$ext" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
  433. fi
  434. fi
  435. done < $SIP_CONFIGURATION_FILE
  436. fi
  437. if [ $SIPEXT ]; then
  438. echo -n -e "$(pad_string SIP:${SIPEXT})"
  439. else
  440. echo -n -e "$(pad_string '')"
  441. fi
  442. # size of the home directory
  443. echo "$(du -s -h /home/${USRNAME} | awk -F ' ' '{print $1}')"
  444. fi
  445. done
  446. echo ''
  447. }
  448. function show_tahoelafs {
  449. if [ ! -f /home/tahoelafs/storage/private/storage.furl ]; then
  450. return
  451. fi
  452. echo 'Tahoe-LAFS Storage Node'
  453. echo '======================='
  454. echo ''
  455. echo "Hostname: $(get_tahoelafs_storage_hostname)"
  456. echo "Public key: $(get_tahoelafs_public_key)"
  457. echo "Nickname: $(get_tahoelafs_nick)"
  458. echo "FURL: $(get_tahoelafs_furl)"
  459. echo ''
  460. }
  461. function show_ip_addresses {
  462. echo $'IP/DNS addresses'
  463. echo '================'
  464. echo ''
  465. echo -n "IPv4: $(get_ipv4_address)/$(get_external_ipv4_address)"
  466. ipv6_address="$(get_ipv6_address)"
  467. if [ ${#ipv6_address} -gt 0 ]; then
  468. echo " IPv6: ${ipv6_address}"
  469. fi
  470. echo ''
  471. echo ''
  472. }
  473. function show_tor_bridges {
  474. bridges_list=$(grep "Bridge " /etc/tor/torrc | grep -v '##')
  475. if [ ${#bridges_list} -gt 0 ]; then
  476. echo $'Tor Bridges'
  477. echo '==========='
  478. echo ''
  479. echo "${bridges_list}"
  480. echo ''
  481. echo ''
  482. fi
  483. if ! grep -q "#BridgeRelay" /etc/tor/torrc; then
  484. if grep -q "BridgeRelay 1" /etc/tor/torrc; then
  485. read_config_param 'TOR_BRIDGE_PORT'
  486. read_config_param 'TOR_BRIDGE_NICKNAME'
  487. if [ ${#TOR_BRIDGE_NICKNAME} -gt 0 ]; then
  488. echo "Tor bridge on this system"
  489. echo '========================='
  490. echo ''
  491. echo "IP Address: $(get_ipv4_address)"
  492. echo "Port: ${TOR_BRIDGE_PORT}"
  493. echo "Nickname: ${TOR_BRIDGE_NICKNAME}"
  494. echo ''
  495. echo ''
  496. fi
  497. fi
  498. fi
  499. }
  500. function show_ssh_public_key {
  501. echo $'SSH Public Keys'
  502. echo '==============='
  503. echo ''
  504. echo "$(get_ssh_server_key)"
  505. echo ''
  506. echo ''
  507. }
  508. function show_tahoelafs_introducer {
  509. INTRODUCER_FILENAME=/home/tahoelafs/data/private/introducer.furl
  510. if [ ! -f $INTRODUCER_FILENAME ]; then
  511. return
  512. fi
  513. echo $'Tahoe-LAFS introducer'
  514. echo '====================='
  515. echo ''
  516. echo "$(cat $INTRODUCER_FILENAME)"
  517. echo ''
  518. echo ''
  519. }
  520. function show_about {
  521. detect_apps
  522. get_apps_installed_names
  523. clear
  524. echo "==== ${PROJECT_NAME} version ${VERSION} ($DEBIAN_VERSION) ===="
  525. echo ''
  526. show_ip_addresses
  527. show_tor_bridges
  528. show_ssh_public_key
  529. show_domains
  530. show_tahoelafs
  531. show_users
  532. any_key
  533. }
  534. function select_user {
  535. SELECTED_USERNAME=
  536. users_array=($(ls /home))
  537. delete=(git)
  538. for del in ${delete[@]}
  539. do
  540. users_array=(${users_array[@]/$del})
  541. done
  542. i=0
  543. W=()
  544. name=()
  545. for u in ${users_array[@]}
  546. do
  547. if [[ $(is_valid_user "$u") == "1" ]]; then
  548. i=$((i+1))
  549. W+=($i "$u")
  550. name+=("$u")
  551. fi
  552. done
  553. if [ $i -eq 1 ]; then
  554. SELECTED_USERNAME="${name[0]}"
  555. else
  556. user_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
  557. if [ $? -eq 0 ]; then
  558. SELECTED_USERNAME="${name[$((user_index-1))]}"
  559. fi
  560. fi
  561. }
  562. function delete_user {
  563. select_user
  564. if [ ! $SELECTED_USERNAME ]; then
  565. return
  566. fi
  567. if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
  568. dialog --title $"Administrator user" \
  569. --msgbox $"You can't delete the administrator user" 6 40
  570. return
  571. fi
  572. clear
  573. ${PROJECT_NAME}-rmuser $SELECTED_USERNAME
  574. any_key
  575. }
  576. function configure_remote_backups {
  577. if ! grep -Fxq "Admin user:$ADMIN_USER" $COMPLETION_FILE; then
  578. dialog --title $"Administrator user" \
  579. --msgbox $"No Administrator user found. Check $COMPLETION_FILE" 6 40
  580. return
  581. fi
  582. if [ ${#ADMIN_USER} -lt 2 ]; then
  583. dialog --title $"Administrator user" \
  584. --msgbox $"Username not found" 6 40
  585. return
  586. fi
  587. if [ ! -d /home/$ADMIN_USER ]; then
  588. dialog --title $"Administrator user" \
  589. --msgbox $"Home directory not found" 6 40
  590. return
  591. fi
  592. ${PROJECT_NAME}-remote -u $ADMIN_USER
  593. if [ ! "$?" = "0" ]; then
  594. any_key
  595. fi
  596. }
  597. function change_password {
  598. select_user
  599. if [ ! $SELECTED_USERNAME ]; then
  600. return
  601. fi
  602. dialog --title $"Change password" \
  603. --passwordbox $"New password for user $SELECTED_USERNAME" 8 40 2> $data
  604. newpassword=$(<$data)
  605. if [ ${#newpassword} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
  606. dialog --title $"Change password" \
  607. --msgbox $"The password should be ${MINIMUM_PASSWORD_LENGTH} or more characters" 6 40
  608. return
  609. fi
  610. echo "$SELECTED_USERNAME:$newpassword"|chpasswd
  611. dialog --title $"Change password" \
  612. --msgbox $"Password for $SELECTED_USERNAME was changed" 6 40
  613. }
  614. function change_ssh_public_key {
  615. select_user
  616. if [ ! $SELECTED_USERNAME ]; then
  617. return
  618. fi
  619. if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
  620. dialog --title $"Change ssh public key" \
  621. --backtitle $"Freedombone Control Panel" \
  622. --defaultno \
  623. --yesno $"\nThis is the administrator user.\n\nAre you sure you want to change the ssh public key for the administrator?" 10 60
  624. sel=$?
  625. case $sel in
  626. 1) return;;
  627. 255) return;;
  628. esac
  629. fi
  630. data=$(tempfile 2>/dev/null)
  631. trap "rm -f $data" 0 1 2 5 15
  632. dialog --title $"Change ssh public key for $SELECTED_USERNAME" \
  633. --backtitle $"Freedombone Control Panel" \
  634. --inputbox $"Paste the ssh public key below" 8 60 2>$data
  635. sel=$?
  636. case $sel in
  637. 0)
  638. SSH_PUBLIC_KEY=$(<$data)
  639. if [ "$SSH_PUBLIC_KEY" ]; then
  640. if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
  641. if [ -f "$SSH_PUBLIC_KEY" ]; then
  642. if [ ! -d /home/$SELECTED_USERNAME/.ssh ]; then
  643. mkdir /home/$SELECTED_USERNAME/.ssh
  644. fi
  645. cp $SSH_PUBLIC_KEY \
  646. /home/$SELECTED_USERNAME/.ssh/authorized_keys
  647. chown -R $SELECTED_USERNAME:$SELECTED_USERNAME \
  648. /home/$SELECTED_USERNAME/.ssh
  649. dialog --title $"Change ssh public key" \
  650. --msgbox $"ssh public key was installed" 6 40
  651. else
  652. if [[ "$SSH_PUBLIC_KEY" == "ssh-"* ]]; then
  653. if [ ! -d /home/$SELECTED_USERNAME/.ssh ]; then
  654. mkdir /home/$SELECTED_USERNAME/.ssh
  655. fi
  656. echo "$SSH_PUBLIC_KEY" > \
  657. /home/$SELECTED_USERNAME/.ssh/authorized_keys
  658. chown -R $SELECTED_USERNAME:$SELECTED_USERNAME \
  659. /home/$SELECTED_USERNAME/.ssh
  660. dialog --title $"Change ssh public key" \
  661. --msgbox $"ssh public key was installed" 6 40
  662. fi
  663. fi
  664. fi
  665. fi
  666. ;;
  667. esac
  668. }
  669. function remove_user_from_mailing_list {
  670. select_user
  671. if [ ! $SELECTED_USERNAME ]; then
  672. return
  673. fi
  674. USER_MAILING_LISTS=$(cat "/home/$SELECTED_USERNAME/.procmailrc" | grep '\[' | grep '\]' | awk -F '\[' '{print $2}' | awk -F '\\' '{print $1}')
  675. i=0
  676. W=()
  677. list_name=()
  678. while read -r listname; do
  679. i=$((i+1))
  680. W+=($i "$listname")
  681. list_name+=("$listname")
  682. echo $listname
  683. done <<< "$USER_MAILING_LISTS"
  684. i=$((i+1))
  685. W+=($i $"Exit back to user mainenance")
  686. list_selected=$(dialog --default-item "$i" --backtitle $"Freedombone Control Panel" --title $"Remove a mailing list for $SELECTED_USERNAME" --menu $"Select one of the following:" 24 50 17 "${W[@]}" 3>&2 2>&1 1>&3)
  687. if [ $? -eq 0 ]; then # Exit with OK
  688. if [ ${list_selected} -ne ${i} ]; then
  689. remove_list_name="${list_name[$((list_selected-1))]}"
  690. # find the line number where the list is defined
  691. line_number=0
  692. i=0
  693. while read -r line
  694. do
  695. if [[ "$line" == *"\[${remove_list_name}\\]"* ]]; then
  696. line_number=${i}
  697. fi
  698. i=$((i+1))
  699. done < "/home/$SELECTED_USERNAME/.procmailrc"
  700. if [ ${line_number} -eq 0 ]; then
  701. # no match was found
  702. return
  703. fi
  704. # recreate the file
  705. if [ -f /home/${SELECTED_USERNAME}/.procmailrc_new ]; then
  706. rm /home/${SELECTED_USERNAME}/.procmailrc_new
  707. fi
  708. i=0
  709. clip=0
  710. while read -r line
  711. do
  712. i=$((i+1))
  713. if [ ${i} -gt $((line_number-1)) ]; then
  714. if [ ${clip} -eq 0 ]; then
  715. clip=1
  716. fi
  717. if [ ${clip} -eq 1 ]; then
  718. if [ ${i} -lt $((line_number+2)) ]; then
  719. continue
  720. else
  721. if [ ${#line} -lt 1 ]; then
  722. clip=2
  723. continue
  724. fi
  725. if [[ "$line" == ":"* || "$line" == "#"* ]]; then
  726. clip=2
  727. else
  728. continue
  729. fi
  730. fi
  731. fi
  732. fi
  733. echo "$line" >> /home/${SELECTED_USERNAME}/.procmailrc_new
  734. if [[ "$line" == *"\[${remove_list_name}\\]"* ]]; then
  735. line_number=${i}
  736. fi
  737. done < "/home/$SELECTED_USERNAME/.procmailrc"
  738. cp /home/${SELECTED_USERNAME}/.procmailrc_new /home/${SELECTED_USERNAME}/.procmailrc
  739. rm /home/${SELECTED_USERNAME}/.procmailrc_new
  740. chown ${SELECTED_USERNAME}:${SELECTED_USERNAME} /home/${SELECTED_USERNAME}/.procmailrc
  741. dialog --title $"Remove user from mailing list" \
  742. --msgbox $"${SELECTED_USERNAME} has been removed from ${remove_list_name}" 6 50
  743. fi
  744. fi
  745. }
  746. function add_to_mailing_list {
  747. select_user
  748. if [ ! $SELECTED_USERNAME ]; then
  749. return
  750. fi
  751. data=$(tempfile 2>/dev/null)
  752. trap "rm -f $data" 0 1 2 5 15
  753. dialog --backtitle $"Freedombone Control Panel" \
  754. --title $"Subscribe $SELECTED_USERNAME to a mailing list" \
  755. --form $"You can either enter a subject or an email address\n" 11 68 4 \
  756. $"List folder name:" 1 1 "" 1 35 26 25 \
  757. $"Name between [] on subject line:" 2 1 "" 2 35 26 25 \
  758. $"List email address:" 3 1 "" 3 35 26 25 \
  759. $"Public:" 4 1 $"yes" 4 35 4 25 \
  760. 2> $data
  761. sel=$?
  762. case $sel in
  763. 1) return;;
  764. 255) return;;
  765. esac
  766. LIST_NAME=$(cat $data | sed -n 1p)
  767. LIST_SUBJECT=$(cat $data | sed -n 2p)
  768. LIST_EMAIL=$(cat $data | sed -n 3p)
  769. LIST_PUBLIC=$(cat $data | sed -n 4p)
  770. if [ ${#LIST_PUBLIC} -lt 1 ]; then
  771. LIST_PUBLIC='no'
  772. fi
  773. if [[ $LIST_PUBLIC == $'y' || $LIST_PUBLIC == $'Y' || $LIST_PUBLIC == $'true' || $LIST_PUBLIC == $'True' || $LIST_PUBLIC == $'yes' || $LIST_PUBLIC == $'Yes' || $LIST_PUBLIC == $'YES' ]]; then
  774. LIST_PUBLIC='yes'
  775. else
  776. LIST_PUBLIC='no'
  777. fi
  778. if [ ${#LIST_NAME} -lt 2 ]; then
  779. dialog --title $"Add mailing list" \
  780. --msgbox $"No mailing list name was given" 6 40
  781. return
  782. fi
  783. if [ ${#LIST_SUBJECT} -lt 2 ]; then
  784. if [ ${#LIST_EMAIL} -lt 2 ]; then
  785. dialog --title $"Add mailing list" \
  786. --msgbox $"No mailing list subject or address was given" 6 40
  787. return
  788. fi
  789. fi
  790. if [ ${#LIST_SUBJECT} -gt 1 ]; then
  791. ${PROJECT_NAME}-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" \
  792. -s "$LIST_SUBJECT" --public $LIST_PUBLIC
  793. else
  794. if [[ "$LIST_EMAIL" != *"@"* || "$LIST_EMAIL" != *"."* ]]; then
  795. dialog --title $"Add mailing list" \
  796. --msgbox $"Unrecognised email address" 6 40
  797. return
  798. else
  799. ${PROJECT_NAME}-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" \
  800. -e "$LIST_EMAIL" --public $LIST_PUBLIC
  801. fi
  802. fi
  803. dialog --title $"Add mailing list" \
  804. --msgbox $"$LIST_NAME list was added" 6 40
  805. }
  806. function email_rule {
  807. select_user
  808. if [ ! $SELECTED_USERNAME ]; then
  809. return
  810. fi
  811. data=$(tempfile 2>/dev/null)
  812. trap "rm -f $data" 0 1 2 5 15
  813. dialog --backtitle $"Freedombone Control Panel" \
  814. --title $"Email rule for user $SELECTED_USERNAME" \
  815. --form "\n" 9 65 4 \
  816. $"When email arrives from address:" 1 1 "" 1 35 24 28 \
  817. $"Move to folder:" 2 1 "" 2 35 24 28 \
  818. $"Public:" 3 1 $"no" 3 35 4 25 \
  819. 2> $data
  820. sel=$?
  821. case $sel in
  822. 1) return;;
  823. 255) return;;
  824. esac
  825. RULE_EMAIL=$(cat $data | sed -n 1p)
  826. RULE_FOLDER=$(cat $data | sed -n 2p)
  827. RULE_PUBLIC=$(cat $data | sed -n 3p)
  828. if [ ${#RULE_PUBLIC} -lt 1 ]; then
  829. RULE_PUBLIC='no'
  830. fi
  831. if [[ $RULE_PUBLIC == $'y' || $RULE_PUBLIC == $'Y' || $RULE_PUBLIC == $'true' || $RULE_PUBLIC == $'True' || $RULE_PUBLIC == $'yes' || $RULE_PUBLIC == $'Yes' || $RULE_PUBLIC == $'YES' ]]; then
  832. RULE_PUBLIC='yes'
  833. else
  834. RULE_PUBLIC='no'
  835. fi
  836. if [ ${#RULE_EMAIL} -lt 2 ]; then
  837. dialog --title $"Add email rule" \
  838. --msgbox $"No email address was given" 6 40
  839. return
  840. fi
  841. if [ ${#RULE_FOLDER} -lt 2 ]; then
  842. dialog --title $"Add email rule" \
  843. --msgbox $"No folder name was given" 6 40
  844. return
  845. fi
  846. if [[ "$RULE_EMAIL" != *"@"* || "$RULE_EMAIL" != *"."* ]]; then
  847. dialog --title $"Add email rule" \
  848. --msgbox $"Unrecognised email address" 6 40
  849. return
  850. fi
  851. ${PROJECT_NAME}-addemail -u $SELECTED_USERNAME -e "$RULE_EMAIL" \
  852. -g "$RULE_FOLDER" --public $RULE_PUBLIC
  853. dialog --title $"Add email rule" \
  854. --msgbox $"Email rule for $RULE_EMAIL was added" 6 40
  855. }
  856. function block_unblock_email {
  857. select_user
  858. if [ ! $SELECTED_USERNAME ]; then
  859. return
  860. fi
  861. blockstr=$"Block/Unblock email going to"
  862. data=$(tempfile 2>/dev/null)
  863. trap "rm -f $data" 0 1 2 5 15
  864. dialog --backtitle $"Freedombone Control Panel" \
  865. --title "$blockstr $SELECTED_USERNAME" \
  866. --form "\n" 8 65 3 \
  867. $"When email arrives from address:" 1 1 "" 1 35 24 100 \
  868. $"Block it:" 2 1 "yes" 2 35 4 4 \
  869. 2> $data
  870. sel=$?
  871. case $sel in
  872. 1) return;;
  873. 255) return;;
  874. esac
  875. BLOCK_EMAIL=$(cat $data | sed -n 1p)
  876. BLOCK=$(cat $data | sed -n 2p)
  877. if [ ${#BLOCK_EMAIL} -lt 2 ]; then
  878. dialog --title $"Block/Unblock an email" \
  879. --msgbox $"No email address was given" 6 40
  880. return
  881. fi
  882. if [[ "$BLOCK_EMAIL" != *"@"* || "$BLOCK_EMAIL" != *"."* ]]; then
  883. dialog --title $"Block/Unblock an email" \
  884. --msgbox $"Unrecognised email address" 6 40
  885. return
  886. fi
  887. if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
  888. ${PROJECT_NAME}-ignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
  889. dialog --title $"Block an email" \
  890. --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME blocked" 6 75
  891. else
  892. ${PROJECT_NAME}-unignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
  893. dialog --title $"Unblock an email" \
  894. --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME unblocked" 6 75
  895. fi
  896. }
  897. function block_unblock_subject {
  898. select_user
  899. if [ ! $SELECTED_USERNAME ]; then
  900. return
  901. fi
  902. blockstr=$"Block/Unblock email going to"
  903. data=$(tempfile 2>/dev/null)
  904. trap "rm -f $data" 0 1 2 5 15
  905. dialog --backtitle $"Freedombone Control Panel" \
  906. --title "$blockstr $SELECTED_USERNAME" \
  907. --form "\n" 8 70 3 \
  908. $"When email arrives with subject text:" 1 1 "" 1 40 24 28 \
  909. $"Block it:" 2 1 "yes" 2 40 4 4 \
  910. 2> $data
  911. sel=$?
  912. case $sel in
  913. 1) return;;
  914. 255) return;;
  915. esac
  916. BLOCK_SUBJECT=$(cat $data | sed -n 1p)
  917. BLOCK=$(cat $data | sed -n 2p)
  918. if [ ${#BLOCK_SUBJECT} -lt 2 ]; then
  919. dialog --title $"Block/Unblock an email" \
  920. --msgbox $"No subject was given" 6 40
  921. return
  922. fi
  923. if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
  924. ${PROJECT_NAME}-ignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
  925. dialog --title $"Block an email" \
  926. --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME blocked" 6 40
  927. else
  928. ${PROJECT_NAME}-unignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
  929. dialog --title $"Unblock an email" \
  930. --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME unblocked" 6 40
  931. fi
  932. }
  933. function create_keydrive_master {
  934. select_user
  935. if [ ! $SELECTED_USERNAME ]; then
  936. return
  937. fi
  938. dialog --title $"USB Master Keydrive" \
  939. --msgbox $"Plug in a LUKS encrypted USB drive" 6 40
  940. clear
  941. detect_usb_drive
  942. ${PROJECT_NAME}-keydrive -u $SELECTED_USERNAME --master 'yes' -d $USB_DRIVE
  943. any_key
  944. }
  945. function create_keydrive_fragment {
  946. select_user
  947. if [ ! $SELECTED_USERNAME ]; then
  948. return
  949. fi
  950. dialog --title $"USB Fragment Keydrive" \
  951. --msgbox $"Plug in a LUKS encrypted USB drive" 6 40
  952. clear
  953. detect_usb_drive
  954. ${PROJECT_NAME}-keydrive -u $SELECTED_USERNAME -d $USB_DRIVE
  955. any_key
  956. }
  957. function backup_data {
  958. dialog --title $"Backup data to USB" \
  959. --msgbox $"Plug in a LUKS encrypted USB drive" 6 40
  960. clear
  961. detect_usb_drive
  962. echo ''
  963. echo $"Detected USB drive $USB_DRIVE"
  964. echo ''
  965. echo $'Enter the passphrase for your LUKS encrypted backup drive:'
  966. ${PROJECT_NAME}-backup-local
  967. any_key
  968. }
  969. function restore_data_from_storage {
  970. restore_type="$1"
  971. AllStr=$"all"
  972. ExitStr=$"Exit"
  973. RestoreStr=$"Restore apps"
  974. if [[ $restore_type != "local" ]]; then
  975. restore_command="${PROJECT_NAME}-restore-remote $remote_domain_name configuration;;"
  976. else
  977. remote_domain_name="$1"
  978. detect_usb_drive
  979. restore_command="${PROJECT_NAME}-restore-local $USB_DRIVE"
  980. RestoreStr=$"Restore apps from USB drive $USB_DRIVE"
  981. fi
  982. utils_installed=(configfiles
  983. blocklist
  984. mariadb
  985. letsencrypt
  986. passwords
  987. mutt
  988. gpg
  989. procmail
  990. spamassassin
  991. readme
  992. ssh
  993. userconfig
  994. userlocal
  995. userfin
  996. certs
  997. personal
  998. email)
  999. detect_apps
  1000. while true
  1001. do
  1002. app_list=()
  1003. n=1
  1004. applist="$n $AllStr off"
  1005. n=$[n+1]
  1006. app_list+=("$AllStr")
  1007. util_index=0
  1008. for a in "${utils_installed[@]}"
  1009. do
  1010. applist="$applist $n $a off"
  1011. app_name=${utils_installed[util_index]}
  1012. n=$[n+1]
  1013. util_index=$[util_index+1]
  1014. app_list+=("$app_name")
  1015. done
  1016. app_index=0
  1017. for a in "${APPS_INSTALLED_NAMES[@]}"
  1018. do
  1019. applist="$applist $n $a off"
  1020. n=$[n+1]
  1021. app_name=${APPS_INSTALLED_NAMES[app_index]}
  1022. app_index=$[app_index+1]
  1023. app_list+=("$app_name")
  1024. done
  1025. applist="$applist $n $ExitStr on"
  1026. n=$[n+1]
  1027. app_list+=("$ExitStr")
  1028. choice=$(dialog --stdout --backtitle $"Freedombone" \
  1029. --title "$RestoreStr" \
  1030. --radiolist $'Choose:' \
  1031. 30 50 20 $applist)
  1032. if [ $? -ne 0 ]; then
  1033. break
  1034. fi
  1035. app_index=$[choice-1]
  1036. app_name=${app_list[app_index]}
  1037. # exit
  1038. if [[ "$app_name" == "$ExitStr" ]]; then
  1039. break
  1040. fi
  1041. clear
  1042. # Restore all
  1043. if [[ "$app_name" == "$AllStr" ]]; then
  1044. $restore_command
  1045. retcode="$?"
  1046. if [[ "$retcode" != "0" ]]; then
  1047. any_key
  1048. if [[ "$1" == "local" ]]; then
  1049. dialog --title $"Restore all apps from USB" \
  1050. --msgbox $"Restore failed with code $retcode" 6 60
  1051. else
  1052. dialog --title $"Restore all apps from $1" \
  1053. --msgbox $"Restore failed with code $retcode" 6 60
  1054. fi
  1055. break
  1056. fi
  1057. if [[ "$1" == "local" ]]; then
  1058. dialog --title $"Restore all apps from USB" \
  1059. --msgbox $"Restore complete" 6 40
  1060. else
  1061. dialog --title $"Restore all apps from $1" \
  1062. --msgbox $"Restore complete" 6 40
  1063. fi
  1064. break
  1065. fi
  1066. # Restore an app
  1067. $restore_command "${app_name}"
  1068. retcode="$?"
  1069. if [[ "$retcode" != "0" ]]; then
  1070. any_key
  1071. dialog --title $"Restore apps from USB" \
  1072. --msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
  1073. return
  1074. fi
  1075. # finished
  1076. if [[ "$1" == "local" ]]; then
  1077. dialog --title $"Restore apps from USB" \
  1078. --msgbox $"Restore complete" 6 40
  1079. else
  1080. dialog --title $"Restore apps from $1" \
  1081. --msgbox $"Restore complete" 6 40
  1082. fi
  1083. done
  1084. }
  1085. function restore_data {
  1086. dialog --title $"Restore data from USB" \
  1087. --msgbox $"Plug in your backup USB drive" 6 40
  1088. clear
  1089. echo ' '
  1090. echo $'Enter the passphrase for your LUKS encrypted backup drive:'
  1091. restore_data_from_storage local
  1092. }
  1093. function restore_data_remote {
  1094. if [ ! $ADMIN_USER ]; then
  1095. dialog --title $"Restore data from remote server" \
  1096. --msgbox $"Unknown admin user" 6 40
  1097. return
  1098. fi
  1099. data=$(tempfile 2>/dev/null)
  1100. trap "rm -f $data" 0 1 2 5 15
  1101. dialog --title $"Restore from remote server" \
  1102. --backtitle $"Freedombone Control Panel" \
  1103. --inputbox $"Enter the domain name of the server from which you wish to restore" 8 60 2>$data
  1104. sel=$?
  1105. case $sel in
  1106. 0)
  1107. friend_server_domain_name=$(<$data)
  1108. if [ ${#friend_server_domain_name} -lt 2 ]; then
  1109. return
  1110. fi
  1111. if [[ $friend_server_domain_name != *"."* ]]; then
  1112. dialog --title $"Remote server domain name" \
  1113. --msgbox $"Invalid domain name" 6 40
  1114. return
  1115. fi
  1116. restore_data_from_storage $friend_server_domain_name
  1117. ;;
  1118. esac
  1119. }
  1120. function ping_enable_disable {
  1121. ping_str=$"\nDo you want to enable other systems to ping this machine?\n\nPing may be useful for diagnostic purposes, but for added security you may not want to enable it."
  1122. enable_ping="no"
  1123. dialog --title $"Enable Ping / ICMP" \
  1124. --backtitle $"Freedombone Control Panel" \
  1125. --defaultno \
  1126. --yesno "$ping_str" 10 60
  1127. sel=$?
  1128. case $sel in
  1129. 0) enable_ping="yes";;
  1130. 255) return;;
  1131. esac
  1132. if [[ $enable_ping == "yes" ]]; then
  1133. iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
  1134. iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
  1135. echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all
  1136. else
  1137. iptables -D INPUT -p icmp --icmp-type echo-request -j ACCEPT
  1138. iptables -D OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
  1139. echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
  1140. fi
  1141. }
  1142. function logging_on_off {
  1143. logging="no"
  1144. dialog --title $"Logging" \
  1145. --backtitle $"Freedombone Control Panel" \
  1146. --defaultno \
  1147. --yesno $"\nDo you want to turn logging on?" 7 60
  1148. sel=$?
  1149. case $sel in
  1150. 0) logging="yes";;
  1151. 255) return;;
  1152. esac
  1153. clear
  1154. echo ''
  1155. echo $'This may take a few seconds. Please wait...'
  1156. if [[ $logging == "no" ]]; then
  1157. ${PROJECT_NAME}-logging off
  1158. else
  1159. ${PROJECT_NAME}-logging on
  1160. fi
  1161. }
  1162. function restore_gpg_key {
  1163. select_user
  1164. if [ ! $SELECTED_USERNAME ]; then
  1165. return
  1166. fi
  1167. restorestr=$"Restore GPG key for user"
  1168. dialog --title "$restorestr $SELECTED_USERNAME" \
  1169. --msgbox $"Plug in your USB keydrive" 6 40
  1170. clear
  1171. ${PROJECT_NAME}-recoverkey -u $SELECTED_USERNAME
  1172. any_key
  1173. }
  1174. function security_settings {
  1175. ${PROJECT_NAME}-sec
  1176. any_key
  1177. }
  1178. function show_tripwire_verification_code {
  1179. if [ ! -f /var/lib/tripwire/${HOSTNAME}.twd ]; then
  1180. return
  1181. fi
  1182. clear
  1183. echo ''
  1184. echo $'Tripwire Verification Code'
  1185. echo ''
  1186. DBHASH=$(sha512sum /var/lib/tripwire/${HOSTNAME}.twd)
  1187. echo -n "$DBHASH" | qrencode -t UTF8
  1188. echo ''
  1189. echo "$DBHASH"
  1190. echo ''
  1191. }
  1192. function reset_tripwire {
  1193. if [ ! -f /usr/bin/reset-tripwire ]; then
  1194. echo $'Missing /usr/bin/reset-tripwire'
  1195. any_key
  1196. return
  1197. fi
  1198. if [ ! -f /etc/tripwire/${HOSTNAME}-local.key ]; then
  1199. echo $'Error: missing local key'
  1200. any_key
  1201. return
  1202. fi
  1203. clear
  1204. echo $'Turing off logging...'
  1205. ${PROJECT_NAME}-logging off
  1206. echo $'Locking down permissions...'
  1207. lockdown_permissions
  1208. echo $'Creating configuration...'
  1209. echo '
  1210. ' | twadmin --create-cfgfile -S /etc/tripwire/${HOSTNAME}-site.key /etc/tripwire/twcfg.txt
  1211. echo $'Resetting policy...'
  1212. echo '
  1213. ' | twadmin --create-polfile -S /etc/tripwire/${HOSTNAME}-site.key /etc/tripwire/twpol.txt
  1214. echo $'Creating tripwire database'
  1215. echo '
  1216. ' | tripwire --init --cfgfile /etc/tripwire/tw.cfg --polfile /etc/tripwire/tw.pol --dbfile /var/lib/tripwire/${HOSTNAME}.twd
  1217. echo $'Resetting the Tripwire...'
  1218. echo ''
  1219. echo '
  1220. ' | reset-tripwire
  1221. echo ''
  1222. # Sometimes nginx fails to restart if matrix is installed
  1223. # Restart matrix first
  1224. if [ -d /etc/matrix ]; then
  1225. systemctl restart matrix
  1226. systemctl restart nginx
  1227. fi
  1228. if [ -f /var/lib/tripwire/${HOSTNAME}.twd ]; then
  1229. show_tripwire_verification_code
  1230. echo $'Tripwire is now reset. Take a note of the above hash, or record'
  1231. echo $'the QR code using a mobile device. This will enable you to independently'
  1232. echo $'verify the integrity of the tripwire.'
  1233. else
  1234. echo $'ERROR: tripwire database was not created'
  1235. fi
  1236. any_key
  1237. }
  1238. function format_drive {
  1239. detect_usb_drive
  1240. data=$(tempfile 2>/dev/null)
  1241. trap "rm -f $data" 0 1 2 5 15
  1242. dialog --title $"Format USB drive $USB_DRIVE" \
  1243. --backtitle $"Freedombone Control Panel" \
  1244. --defaultno \
  1245. --yesno $"\nPlease confirm that you wish to format drive\n\n ${USB_DRIVE}\n\nAll current data on the drive will be lost, and you will be prompted to give a password used to encrypt the drive.\n\nDANGER: If you screw up here and format the wrong drive it's your own fault!" 16 60
  1246. sel=$?
  1247. case $sel in
  1248. 1) return;;
  1249. 255) return;;
  1250. esac
  1251. clear
  1252. echo ''
  1253. echo $"Formatting drive $USB_DRIVE. ALL CONTENTS WILL BE LOST."
  1254. echo ''
  1255. ${PROJECT_NAME}-format $USB_DRIVE
  1256. any_key
  1257. }
  1258. function remove_backups {
  1259. detect_usb_drive
  1260. data=$(tempfile 2>/dev/null)
  1261. trap "rm -f $data" 0 1 2 5 15
  1262. dialog --title $"Remove backups from a USB drive $USB_DRIVE" \
  1263. --backtitle $"Freedombone Control Panel" \
  1264. --defaultno \
  1265. --yesno $"\nPlease confirm that you wish to remove backups from this drive\n\n ${drive}\n\nYou will not be able to recover them afterwards." 12 60
  1266. sel=$?
  1267. case $sel in
  1268. 1) return;;
  1269. 255) return;;
  1270. esac
  1271. clear
  1272. ${PROJECT_NAME}-backup-local $USB_DRIVE remove
  1273. any_key
  1274. }
  1275. function shut_down_system {
  1276. dialog --title $"Power off the system" \
  1277. --backtitle $"Freedombone Control Panel" \
  1278. --defaultno \
  1279. --yesno $"\nPlease confirm that you wish to power off the system.\n\nWARNING: to power on again you will need to have physical access to the hardware." 10 60
  1280. sel=$?
  1281. case $sel in
  1282. 1) return;;
  1283. 255) return;;
  1284. esac
  1285. systemctl poweroff
  1286. }
  1287. function restart_system {
  1288. dialog --title $"Restart the system" \
  1289. --backtitle $"Freedombone Control Panel" \
  1290. --defaultno \
  1291. --yesno $"\nPlease confirm that you wish to restart the system.\n\nWARNING: If you are using full disk encryption then you will need physical access to the hardware to type in the password" 10 60
  1292. sel=$?
  1293. case $sel in
  1294. 1) return;;
  1295. 255) return;;
  1296. esac
  1297. systemctl reboot -i
  1298. }
  1299. function change_system_name {
  1300. data=$(tempfile 2>/dev/null)
  1301. trap "rm -f $data" 0 1 2 5 15
  1302. dialog --title $"Change the name of this system" \
  1303. --backtitle $"Freedombone Control Panel" \
  1304. --inputbox $'Enter a new name for this system on your local network\n\nIt will appear as newname.local' 10 60 2>$data
  1305. sel=$?
  1306. case $sel in
  1307. 0) NEW_SYSTEM_NAME=$(<$data)
  1308. if [ "$NEW_SYSTEM_NAME" ]; then
  1309. if [ ${#NEW_SYSTEM_NAME} -gt 1 ]; then
  1310. sed -i "s|host-name=.*|host-name=$NEW_SYSTEM_NAME|g" /etc/avahi/avahi-daemon.conf
  1311. systemctl restart avahi-daemon
  1312. if grep -q "host-name=$NEW_SYSTEM_NAME" /etc/avahi/avahi-daemon.conf; then
  1313. dialog --title $"New local network name" \
  1314. --msgbox $"The name of this system on your local network was changed successfully" 6 70
  1315. fi
  1316. fi
  1317. fi
  1318. ;;
  1319. esac
  1320. }
  1321. function set_dynamic_IP {
  1322. revert_to_dynamic=
  1323. dialog --title $"Return to using a dynamic IP address" \
  1324. --backtitle $"Freedombone Control Panel" \
  1325. --yesno $"\nDo you wish to go back to using a dynamic IP address?" 8 60
  1326. sel=$?
  1327. case $sel in
  1328. 0) revert_to_dynamic=1
  1329. ;;
  1330. 1) return;;
  1331. esac
  1332. if [ $revert_to_dynamic ]; then
  1333. wifi_original_network_settings
  1334. clear
  1335. echo ''
  1336. echo $'Changing to a dynamic IP address.'
  1337. echo ''
  1338. echo $"System is rebooting. You may need to close this terminal and log in from a new one."
  1339. systemctl reboot -i
  1340. fi
  1341. }
  1342. function set_static_IP {
  1343. IPv4_address=$(get_ipv4_address)
  1344. IPv4_address_base=$(echo "$IPv4_address" | awk -F '.' '{print $1"."$2"."$3}')
  1345. STATIC_IP="${IPv4_address_base}.60"
  1346. STATIC_GATEWAY="${IPv4_address_base}.1"
  1347. NEW_STATIC_IP=
  1348. NEW_STATIC_GATEWAY=
  1349. if [ -f /etc/network/interfaces.d/static ]; then
  1350. STATIC_IP=$(cat /etc/network/interfaces.d/static | grep "address " | head -n 1 | awk -F ' ' '{print $2}')
  1351. STATIC_GATEWAY=$(cat /etc/network/interfaces.d/static | grep "gateway " | head -n 1 | awk -F ' ' '{print $2}')
  1352. fi
  1353. # get the IP for the box
  1354. data=$(tempfile 2>/dev/null)
  1355. trap "rm -f $data" 0 1 2 5 15
  1356. dialog --title $"Set a static local IP address" \
  1357. --backtitle $"Freedombone Control Panel" \
  1358. --inputbox $"In order to forward incoming internet traffic to this system most internet routers need to know a static local IP address to send the data to.\n\n
  1359. Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_address_base}.x\n\nIf you leave this field blank then the system will revert to using a dynamic IP address." 18 60 "$STATIC_IP" 2>$data
  1360. sel=$?
  1361. case $sel in
  1362. 0) NEW_STATIC_IP=$(<$data)
  1363. if [[ "$NEW_STATIC_IP" != *"."* ]]; then
  1364. set_dynamic_IP
  1365. return
  1366. fi
  1367. ;;
  1368. 1) return;;
  1369. esac
  1370. # get the gateway
  1371. data=$(tempfile 2>/dev/null)
  1372. trap "rm -f $data" 0 1 2 5 15
  1373. dialog --title $"Set the IP address of your internet router/modem" \
  1374. --backtitle $"Freedombone Control Panel" \
  1375. --inputbox $"Set the local IP address for your internet router or ADSL modem.\n\nIt will typically be ${IPv4_address_base}.1, ${IPv4_address_base}.254, or similar" 12 60 "$STATIC_GATEWAY" 2>$data
  1376. sel=$?
  1377. case $sel in
  1378. 0) NEW_STATIC_GATEWAY=$(<$data)
  1379. if [[ "$NEW_STATIC_GATEWAY" != *"."* ]]; then
  1380. return
  1381. fi
  1382. ;;
  1383. 1) return;;
  1384. esac
  1385. if [[ "$NEW_STATIC_GATEWAY" == *"."* && "$NEW_STATIC_IP" == *"."* ]]; then
  1386. ip_addresses_have_changed=1
  1387. if [ -f /etc/network/interfaces.d/static ]; then
  1388. ip_addresses_have_changed=
  1389. if ! grep -q "address ${NEW_STATIC_IP}" /etc/network/interfaces.d/static; then
  1390. ip_addresses_have_changed=1
  1391. fi
  1392. if ! grep -q "gateway ${NEW_STATIC_GATEWAY}" /etc/network/interfaces.d/static; then
  1393. ip_addresses_have_changed=1
  1394. fi
  1395. fi
  1396. if [ $ip_addresses_have_changed ]; then
  1397. write_config_param "NETWORK_IS_STATIC" "1"
  1398. write_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS" "$NEW_STATIC_IP"
  1399. write_config_param "ROUTER_IP_ADDRESS" "$NEW_STATIC_GATEWAY"
  1400. email_change_relay "$NEW_STATIC_IP"
  1401. static_wifi_address=
  1402. if [[ $(config_param_exists "WIFI_INTERFACE") == "1" ]]; then
  1403. dialog --title $"Static local IP address" \
  1404. --backtitle $"Freedombone Control Panel" \
  1405. --yesno $"\nSet a static address for the wifi adapter?\n\nIf you select 'no' then wired ethernet will be used." 10 60
  1406. sel=$?
  1407. case $sel in
  1408. 0) static_wifi_address=1
  1409. write_config_param "NETWORK_IS_STATIC" "1"
  1410. ;;
  1411. esac
  1412. fi
  1413. echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
  1414. echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
  1415. echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces
  1416. if [ ! $static_wifi_address ]; then
  1417. # wired network
  1418. remove_wifi_startup_script
  1419. echo 'auto eth0' > /etc/network/interfaces.d/static
  1420. echo 'iface eth0 inet static' >> /etc/network/interfaces.d/static
  1421. echo " address ${NEW_STATIC_IP}" >> /etc/network/interfaces.d/static
  1422. echo ' netmask 255.255.255.0' >> /etc/network/interfaces.d/static
  1423. echo " gateway ${NEW_STATIC_GATEWAY}" >> /etc/network/interfaces.d/static
  1424. else
  1425. # wifi network
  1426. wifi_settings
  1427. fi
  1428. clear
  1429. echo ''
  1430. echo $'Restarting the network daemon.'
  1431. echo ''
  1432. echo $'If you logged in using the previous IP address then you may need to close this terminal and log in again on the new one.'
  1433. function_check pihole_change_ipv4
  1434. pihole_change_ipv4 ${NEW_STATIC_IP}
  1435. dialog --title $"Static local IP address" \
  1436. --backtitle $"Freedombone Control Panel" \
  1437. --yesno $"\nFor the change to take effect your system will now need to reboot. Do this now?" 8 60
  1438. sel=$?
  1439. case $sel in
  1440. 0) systemctl reboot -i;;
  1441. esac
  1442. fi
  1443. fi
  1444. }
  1445. function wifi_settings {
  1446. if [ -f /etc/hostapd/hostapd.conf ]; then
  1447. return
  1448. fi
  1449. TEMP_WIFI_NETWORKS_FILE=~/.temp-${PROJECT_NAME}-wifi.cfg
  1450. ${PROJECT_NAME}-wifi --networksinteractive $TEMP_WIFI_NETWORKS_FILE
  1451. if [ -f $TEMP_WIFI_NETWORKS_FILE ]; then
  1452. cp $TEMP_WIFI_NETWORKS_FILE $WIFI_NETWORKS_FILE
  1453. rm $TEMP_WIFI_NETWORKS_FILE
  1454. ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
  1455. create_wifi_startup_script
  1456. if [[ $(wifi_is_running) == "1" ]]; then
  1457. dialog --title $"Wifi Settings" \
  1458. --msgbox $"Wifi settings were changed." 6 60
  1459. else
  1460. dialog --title $"Wifi Settings" \
  1461. --msgbox $"Wifi settings were changed. You will need to restart the system with ethernet cable removed for the changes to take effect." 7 60
  1462. fi
  1463. else
  1464. remove_wifi_startup_script
  1465. fi
  1466. }
  1467. function wifi_edit_networks {
  1468. if [ -f /etc/hostapd/hostapd.conf ]; then
  1469. return
  1470. fi
  1471. if [ ! -f $WIFI_NETWORKS_FILE ]; then
  1472. echo $'# Add wifi networks as follows:' > $WIFI_NETWORKS_FILE
  1473. echo '#' >> $WIFI_NETWORKS_FILE
  1474. echo $'# MySSID' >> $WIFI_NETWORKS_FILE
  1475. echo $'# wpa2-psk' >> $WIFI_NETWORKS_FILE
  1476. echo $'# myWifiPassphrase' >> $WIFI_NETWORKS_FILE
  1477. echo '#' >> $WIFI_NETWORKS_FILE
  1478. echo $'# AnotherSSID' >> $WIFI_NETWORKS_FILE
  1479. echo $'# none' >> $WIFI_NETWORKS_FILE
  1480. echo '#' >> $WIFI_NETWORKS_FILE
  1481. fi
  1482. editor $WIFI_NETWORKS_FILE
  1483. ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
  1484. }
  1485. function hotspot_settings {
  1486. data=$(tempfile 2>/dev/null)
  1487. trap "rm -f $data" 0 1 2 5 15
  1488. dialog --backtitle $"Freedombone Control Panel" \
  1489. --title $"Hotspot Settings" \
  1490. --form $"" 10 60 4 \
  1491. $"Enabled (yes/no):" 1 1 "$WIFI_HOTSPOT" 1 24 5 5 \
  1492. $"SSID:" 2 1 "$WIFI_SSID" 2 24 256 256 \
  1493. $"Type (wpa2-psk/none):" 3 1 "$WIFI_TYPE" 3 24 10 10 \
  1494. $"Passphrase:" 4 1 "$WIFI_PASSPHRASE" 4 24 256 256 \
  1495. 2> $data
  1496. sel=$?
  1497. case $sel in
  1498. 1) return;;
  1499. 255) return;;
  1500. esac
  1501. TEMP_WIFI_HOTSPOT=$(cat $data | sed -n 1p)
  1502. TEMP_WIFI_SSID=$(cat $data | sed -n 2p)
  1503. TEMP_WIFI_TYPE=$(cat $data | sed -n 3p)
  1504. TEMP_WIFI_PASSPHRASE=$(cat $data | sed -n 4p)
  1505. if [ ${#TEMP_WIFI_SSID} -lt 2 ]; then
  1506. return
  1507. fi
  1508. if [ ${#TEMP_WIFI_TYPE} -lt 2 ]; then
  1509. return
  1510. fi
  1511. WIFI_EXTRA=''
  1512. if [[ $TEMP_WIFI_HOTSPOT == $'yes' || $TEMP_WIFI_HOTSPOT == $'y' || $TEMP_WIFI_HOTSPOT == $'on' ]]; then
  1513. TEMP_WIFI_HOTSPOT='yes'
  1514. else
  1515. TEMP_WIFI_HOTSPOT='no'
  1516. if [ -f $WIFI_NETWORKS_FILE ]; then
  1517. WIFI_EXTRA='--networks $WIFI_NETWORKS_FILE'
  1518. fi
  1519. fi
  1520. if [[ $TEMP_WIFI_TYPE != $'none' ]]; then
  1521. if [ ! $TEMP_WIFI_PASSPHRASE ]; then
  1522. dialog --title $"Wifi Settings" \
  1523. --msgbox $"No wifi hotspot passphrase was given" 6 40
  1524. return
  1525. fi
  1526. if [ ${#TEMP_WIFI_PASSPHRASE} -lt 2 ]; then
  1527. dialog --title $"Wifi Settings" \
  1528. --msgbox $"Wifi hotspot passphrase was too short" 6 40
  1529. return
  1530. fi
  1531. WIFI_HOTSPOT=$TEMP_WIFI_HOTSPOT
  1532. WIFI_SSID=$TEMP_WIFI_SSID
  1533. WIFI_TYPE=$TEMP_WIFI_TYPE
  1534. WIFI_PASSPHRASE=$TEMP_WIFI_PASSPHRASE
  1535. ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $WIFI_HOTSPOT $WIFI_EXTRA
  1536. if [ ! "$?" = "0" ]; then
  1537. echo $"Can't enable wifi hotspot"
  1538. any_key
  1539. fi
  1540. else
  1541. WIFI_HOTSPOT=$TEMP_WIFI_HOTSPOT
  1542. WIFI_SSID=$TEMP_WIFI_SSID
  1543. WIFI_TYPE=$TEMP_WIFI_TYPE
  1544. WIFI_PASSPHRASE=$TEMP_WIFI_PASSPHRASE
  1545. ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $WIFI_HOTSPOT $WIFI_EXTRA
  1546. fi
  1547. # store any changes
  1548. write_config_param "WIFI_HOTSPOT" "$WIFI_HOTSPOT"
  1549. write_config_param "WIFI_SSID" "$WIFI_SSID"
  1550. write_config_param "WIFI_TYPE" "$WIFI_TYPE"
  1551. write_config_param "WIFI_PASSPHRASE" "$WIFI_PASSPHRASE"
  1552. dialog --title $"Wifi Settings" \
  1553. --msgbox $"Hotspot settings were changed" 6 40
  1554. }
  1555. function reinstall_mariadb {
  1556. dialog --title $"Reinstall MariaDB" \
  1557. --backtitle $"Freedombone Control Panel" \
  1558. --defaultno \
  1559. --yesno $"\nThis should be a LAST RESORT, if the mysql daemon won't start. You will lose ALL databases and will then need to restore them from backup.\n\nAre you sure that you wish to continue?" 12 60
  1560. sel=$?
  1561. case $sel in
  1562. 1) return;;
  1563. 255) return;;
  1564. esac
  1565. clear
  1566. database_reinstall
  1567. dialog --title $"Reinstall MariaDB" \
  1568. --msgbox $"MariaDB has been reinstalled" 6 40
  1569. }
  1570. function show_firewall {
  1571. clear
  1572. echo $"Firewall Settings"
  1573. echo ''
  1574. while read line; do
  1575. firewall_name=$(echo "$line" | awk -F '=' '{print $1}')
  1576. firewall_port=$(echo "$line" | awk -F '=' '{print $2}')
  1577. echo -n -e "$(pad_string ${firewall_name})"
  1578. echo "${firewall_port}"
  1579. done < $FIREWALL_CONFIG
  1580. any_key
  1581. }
  1582. function email_extra_domains {
  1583. email_hostnames=$(cat /etc/exim4/update-exim4.conf.conf | grep "dc_other_hostnames" | awk -F "'" '{print $2}')
  1584. data=$(tempfile 2>/dev/null)
  1585. trap "rm -f $data" 0 1 2 5 15
  1586. dialog --title $"Email Domains" \
  1587. --backtitle $"Freedombone Control Panel" \
  1588. --inputbox $"Enter the list of email domains to use, separated by semicolons" 8 60 $email_hostnames 2>$data
  1589. sel=$?
  1590. case $sel in
  1591. 0)
  1592. emailhostnames=$(<$data)
  1593. if [ ${#emailhostnames} -gt 2 ]; then
  1594. if [[ "$email_hostnames" != "$emailhostnames" ]]; then
  1595. if [[ "$emailhostnames" == *"."* ]]; then
  1596. if [[ "$emailhostnames" != *" "* ]]; then
  1597. sed -i "s|dc_other_hostnames=.*|dc_other_hostnames='$emailhostnames'|g" /etc/exim4/update-exim4.conf.conf
  1598. update-exim4.conf
  1599. dpkg-reconfigure --frontend noninteractive exim4-config
  1600. systemctl restart saslauthd
  1601. dialog --title $"Email Domains" \
  1602. --backtitle $"Freedombone Control Panel" \
  1603. --msgbox $"Email domains were changed" 6 50
  1604. else
  1605. dialog --title $"Email Domains not set" \
  1606. --backtitle $"Freedombone Control Panel" \
  1607. --msgbox $"There should be no spaces in the list" 6 50
  1608. fi
  1609. fi
  1610. fi
  1611. fi
  1612. ;;
  1613. esac
  1614. }
  1615. function email_smtp_proxy {
  1616. MUTTRC_FILE=/home/$ADMIN_USER/.muttrc
  1617. if [ ! -f $MUTTRC_FILE ]; then
  1618. return
  1619. fi
  1620. data=$(tempfile 2>/dev/null)
  1621. trap "rm -f $data" 0 1 2 5 15
  1622. dialog --backtitle $"Freedombone Control Panel" \
  1623. --title $"SMTP Proxy for $ADMIN_USER" \
  1624. --form $"You may need to proxy outgoing email via your ISP's mail server. If so enter the details below." 14 75 6 \
  1625. $"Enable proxy:" 1 1 "$SMTP_PROXY_ENABLE" 1 24 5 5 \
  1626. $"Protocol (smtp/smtps):" 2 1 "$SMTP_PROXY_PROTOCOL" 2 24 5 5 \
  1627. $"ISP mail server:" 3 1 "$SMTP_PROXY_SERVER" 3 24 40 10000 \
  1628. $"Port:" 4 1 "$SMTP_PROXY_PORT" 4 24 5 5 \
  1629. $"Username:" 5 1 "$SMTP_PROXY_USERNAME" 5 24 40 10000 \
  1630. $"Password:" 6 1 "$SMTP_PROXY_PASSWORD" 6 24 40 10000 \
  1631. 2> $data
  1632. sel=$?
  1633. case $sel in
  1634. 1) return;;
  1635. 255) return;;
  1636. esac
  1637. SMTP_PROXY_ENABLE=$(cat $data | sed -n 1p)
  1638. SMTP_PROXY_PROTOCOL=$(cat $data | sed -n 2p)
  1639. SMTP_PROXY_SERVER=$(cat $data | sed -n 3p)
  1640. SMTP_PROXY_PORT=$(cat $data | sed -n 4p)
  1641. SMTP_PROXY_USERNAME=$(cat $data | sed -n 5p)
  1642. SMTP_PROXY_PASSWORD=$(cat $data | sed -n 6p)
  1643. # change muttrc
  1644. if [ $SMTP_PROXY_ENABLE != $'no' ]; then
  1645. if ! grep -q "set smtp_url" $MUTTRC_FILE; then
  1646. echo "set smtp_url=\"${SMTP_PROXY_PROTOCOL}://${SMTP_PROXY_USERNAME}:${SMTP_PROXY_PASSWORD}@${SMTP_PROXY_SERVER}:${SMTP_PROXY_PORT}/\"" >> $MUTTRC_FILE
  1647. else
  1648. sed -i "s|set smtp_url=.*|set smtp_url=\"${SMTP_PROXY_PROTOCOL}://${SMTP_PROXY_USERNAME}:${SMTP_PROXY_PASSWORD}@${SMTP_PROXY_SERVER}:${SMTP_PROXY_PORT}/\"|g" $MUTTRC_FILE
  1649. fi
  1650. sed -i 's|#set smtp_url|set smtp_url|g' $MUTTRC_FILE
  1651. else
  1652. if grep -q "set smtp_url" $MUTTRC_FILE; then
  1653. sed -i 's|set smtp_url|#set smtp_url|g' $MUTTRC_FILE
  1654. fi
  1655. fi
  1656. # save settings within the main configuration file
  1657. write_config_param "SMTP_PROXY_ENABLE" "$SMTP_PROXY_ENABLE"
  1658. write_config_param "SMTP_PROXY_PROTOCOL" "$SMTP_PROXY_PROTOCOL"
  1659. write_config_param "SMTP_PROXY_SERVER" "$SMTP_PROXY_SERVER"
  1660. write_config_param "SMTP_PROXY_PORT" "$SMTP_PROXY_PORT"
  1661. write_config_param "SMTP_PROXY_USERNAME" "$SMTP_PROXY_USERNAME"
  1662. write_config_param "SMTP_PROXY_PASSWORD" "$SMTP_PROXY_PASSWORD"
  1663. }
  1664. function menu_backup_restore {
  1665. while true
  1666. do
  1667. data=$(tempfile 2>/dev/null)
  1668. trap "rm -f $data" 0 1 2 5 15
  1669. dialog --backtitle $"Freedombone Control Panel" \
  1670. --title $"Backup and Restore" \
  1671. --radiolist $"Choose an operation:" 19 70 12 \
  1672. 1 $"Backup data to USB drive" off \
  1673. 2 $"Restore GPG key from USB keydrive" off \
  1674. 3 $"Restore data from USB drive" off \
  1675. 4 $"Reinstall mariadb" off \
  1676. 5 $"Configure remote backups" off \
  1677. 6 $"Restore from remote backup" off \
  1678. 7 $"Backup GPG key to USB (master keydrive)" off \
  1679. 8 $"Backup GPG key to USB (fragment keydrive)" off \
  1680. 9 $"Format a USB drive (LUKS encrypted)" off \
  1681. 10 $"Remove backups from a USB drive" off \
  1682. 11 $"Back to main menu" on 2> $data
  1683. sel=$?
  1684. case $sel in
  1685. 1) break;;
  1686. 255) break;;
  1687. esac
  1688. case $(cat $data) in
  1689. 1) backup_data;;
  1690. 2) restore_gpg_key;;
  1691. 3) restore_data;;
  1692. 4) reinstall_mariadb;;
  1693. 5) configure_remote_backups;;
  1694. 6) restore_data_remote;;
  1695. 7) create_keydrive_master;;
  1696. 8) create_keydrive_fragment;;
  1697. 9) format_drive;;
  1698. 10) remove_backups;;
  1699. 11) break;;
  1700. esac
  1701. done
  1702. }
  1703. function menu_email {
  1704. while true
  1705. do
  1706. data=$(tempfile 2>/dev/null)
  1707. trap "rm -f $data" 0 1 2 5 15
  1708. dialog --backtitle $"Freedombone Control Panel" \
  1709. --title $"Email Menu" \
  1710. --radiolist $"Choose an operation:" 15 70 8 \
  1711. 1 $"Add a user to a mailing list" off \
  1712. 2 $"Remove a user from a mailing list" off \
  1713. 3 $"Add an email rule" off \
  1714. 4 $"Block/Unblock an email address" off \
  1715. 5 $"Block/Unblock email with subject text" off \
  1716. 6 $"Outgoing Email Proxy" off \
  1717. 7 $"Extra email domains" off \
  1718. 8 $"Back to main menu" on 2> $data
  1719. sel=$?
  1720. case $sel in
  1721. 1) break;;
  1722. 255) break;;
  1723. esac
  1724. case $(cat $data) in
  1725. 1) add_to_mailing_list;;
  1726. 2) remove_user_from_mailing_list;;
  1727. 3) email_rule;;
  1728. 4) block_unblock_email;;
  1729. 5) block_unblock_subject;;
  1730. 6) email_smtp_proxy;;
  1731. 7) email_extra_domains;;
  1732. 8) break;;
  1733. esac
  1734. done
  1735. }
  1736. function domain_blocking_add {
  1737. data=$(tempfile 2>/dev/null)
  1738. trap "rm -f $data" 0 1 2 5 15
  1739. dialog --title $"Block a domain or user" \
  1740. --backtitle $"Freedombone Control Panel" \
  1741. --inputbox $"Enter the domain name or GNU Social/postActiv nick@domain that you wish to block" 8 60 "" 2>$data
  1742. sel=$?
  1743. case $sel in
  1744. 0)
  1745. blocked_domain=$(<$data)
  1746. if [ ${#blocked_domain} -gt 2 ]; then
  1747. if [[ "${blocked_domain}" == *'.'* ]]; then
  1748. firewall_block_domain $blocked_domain
  1749. if [[ "${blocked_domain}" != *'@'* ]]; then
  1750. dialog --title $"Block a domain" \
  1751. --msgbox $"The domain $blocked_domain has been blocked" 6 40
  1752. else
  1753. dialog --title $"Block a GNU Social/postActiv nickname" \
  1754. --msgbox $"$blocked_domain has been blocked" 6 40
  1755. fi
  1756. fi
  1757. fi
  1758. ;;
  1759. esac
  1760. }
  1761. function ip_blocking_add {
  1762. data=$(tempfile 2>/dev/null)
  1763. trap "rm -f $data" 0 1 2 5 15
  1764. dialog --title $"Block an IP address" \
  1765. --backtitle $"Freedombone Control Panel" \
  1766. --inputbox $"Enter the IP address that you wish to block" 8 60 "" 2>$data
  1767. sel=$?
  1768. case $sel in
  1769. 0)
  1770. blocked_ip=$(<$data)
  1771. if [ ${#blocked_ip} -gt 2 ]; then
  1772. if [[ "${blocked_ip}" == *'.'* ]]; then
  1773. firewall_block_ip $blocked_ip
  1774. if [[ "${blocked_ip}" != *'@'* ]]; then
  1775. dialog --title $"Block an IP address" \
  1776. --msgbox $"The IP address $blocked_ip has been blocked" 6 40
  1777. fi
  1778. fi
  1779. fi
  1780. ;;
  1781. esac
  1782. }
  1783. function domain_blocking_remove {
  1784. data=$(tempfile 2>/dev/null)
  1785. trap "rm -f $data" 0 1 2 5 15
  1786. dialog --title $"Unblock a domain or user" \
  1787. --backtitle $"Freedombone Control Panel" \
  1788. --inputbox $"Enter the domain name or GNU Social/postActiv nick@domain that you wish to unblock" 8 60 "" 2>$data
  1789. sel=$?
  1790. case $sel in
  1791. 0)
  1792. unblocked_domain=$(<$data)
  1793. if [ ${#unblocked_domain} -gt 2 ]; then
  1794. if [[ "${unblocked_domain}" == *'.'* ]]; then
  1795. firewall_unblock_domain $unblocked_domain
  1796. if [[ "${unblocked_domain}" != *'@'* ]]; then
  1797. dialog --title $"Unblock a domain" \
  1798. --msgbox $"The domain $unblocked_domain has been unblocked" 6 40
  1799. else
  1800. dialog --title $"Unblock a GNU Social/postActiv nickname" \
  1801. --msgbox $"$unblocked_domain has been unblocked" 6 40
  1802. fi
  1803. fi
  1804. fi
  1805. ;;
  1806. esac
  1807. }
  1808. function ip_blocking_remove {
  1809. data=$(tempfile 2>/dev/null)
  1810. trap "rm -f $data" 0 1 2 5 15
  1811. dialog --title $"Unblock an IP address" \
  1812. --backtitle $"Freedombone Control Panel" \
  1813. --inputbox $"Enter the IP address that you wish to unblock" 8 60 "" 2>$data
  1814. sel=$?
  1815. case $sel in
  1816. 0)
  1817. unblocked_ip=$(<$data)
  1818. if [ ${#unblocked_ip} -gt 2 ]; then
  1819. if [[ "${unblocked_ip}" == *'.'* ]]; then
  1820. firewall_unblock_ip $unblocked_ip
  1821. if [[ "${unblocked_ip}" != *'@'* ]]; then
  1822. dialog --title $"Unblock an IP address" \
  1823. --msgbox $"The IP address $unblocked_ip has been unblocked" 6 40
  1824. fi
  1825. fi
  1826. fi
  1827. ;;
  1828. esac
  1829. }
  1830. function domain_blocking_show {
  1831. if [ -f $FIREWALL_DOMAINS ]; then
  1832. clear
  1833. echo ''
  1834. echo $'The following domains or users have been blocked:'
  1835. echo ''
  1836. cat $FIREWALL_DOMAINS | sort
  1837. any_key
  1838. else
  1839. dialog --title $"Show blocked domains or users" \
  1840. --msgbox $"No domains or users are currently blocked" 6 40
  1841. fi
  1842. }
  1843. function domain_blocking {
  1844. while true
  1845. do
  1846. data=$(tempfile 2>/dev/null)
  1847. trap "rm -f $data" 0 1 2 5 15
  1848. dialog --backtitle $"Freedombone Control Panel" \
  1849. --title $"Domain or User Blocking" \
  1850. --radiolist $"Choose an operation:" 14 60 6 \
  1851. 1 $"Block a domain or user" off \
  1852. 2 $"Unblock a domain or user" off \
  1853. 3 $"Block an IP address" off \
  1854. 4 $"Unblock an IP address" off \
  1855. 5 $"Show blocked domains and users" off \
  1856. 6 $"Back to main menu" on 2> $data
  1857. sel=$?
  1858. case $sel in
  1859. 1) break;;
  1860. 255) break;;
  1861. esac
  1862. case $(cat $data) in
  1863. 1) domain_blocking_add;;
  1864. 2) domain_blocking_remove;;
  1865. 3) ip_blocking_add;;
  1866. 4) ip_blocking_remove;;
  1867. 5) domain_blocking_show;;
  1868. 6) break;;
  1869. esac
  1870. done
  1871. }
  1872. function menu_users {
  1873. while true
  1874. do
  1875. data=$(tempfile 2>/dev/null)
  1876. trap "rm -f $data" 0 1 2 5 15
  1877. dialog --backtitle $"Freedombone Control Panel" \
  1878. --title $"Manage Users" \
  1879. --radiolist $"Choose an operation:" 13 70 6 \
  1880. 1 $"Add a user" off \
  1881. 2 $"Delete a user" off \
  1882. 3 $"Change user password" off \
  1883. 4 $"Change user ssh public key" off \
  1884. 5 $"Reset password tries" off \
  1885. 6 $"Back to main menu" on 2> $data
  1886. sel=$?
  1887. case $sel in
  1888. 1) break;;
  1889. 255) break;;
  1890. esac
  1891. case $(cat $data) in
  1892. 1) add_user;;
  1893. 2) delete_user;;
  1894. 3) change_password;;
  1895. 4) change_ssh_public_key;;
  1896. 5) reset_password_tries;;
  1897. 6) break;;
  1898. esac
  1899. done
  1900. }
  1901. function wifi_enable {
  1902. disable_wifi='yes'
  1903. dialog --title $"Enable Wifi" \
  1904. --backtitle $"Freedombone Control Panel" \
  1905. --defaultno \
  1906. --yesno $"\nDo you wish to enable wifi?" 10 50
  1907. sel=$?
  1908. case $sel in
  1909. 0) disable_wifi='no';;
  1910. 1) disable_wifi='yes';;
  1911. 255) return;;
  1912. esac
  1913. ${PROJECT_NAME}-wifi --disable $disable_wifi
  1914. }
  1915. function menu_wifi {
  1916. if [[ "$(wifi_exists)" == "0" ]]; then
  1917. dialog --title $"Wifi" \
  1918. --msgbox $"No wifi adaptors were detected" 6 40
  1919. return
  1920. fi
  1921. while true
  1922. do
  1923. status_str=$'Wifi OFF'
  1924. if [ -f /etc/hostapd/hostapd.conf ]; then
  1925. status_str=$'Hotspot ON'
  1926. else
  1927. if [ -f /etc/network/interfaces.d/wifi ]; then
  1928. status_str=$'Wifi ON'
  1929. fi
  1930. fi
  1931. data=$(tempfile 2>/dev/null)
  1932. trap "rm -f $data" 0 1 2 5 15
  1933. dialog --backtitle $"Freedombone Control Panel" \
  1934. --title $"Wifi Menu" \
  1935. --radiolist $"${status_str}\n\nChoose an operation:" 14 70 6 \
  1936. 1 $"Enable or disable Wifi" off \
  1937. 2 $"Configure wifi networks" off \
  1938. 3 $"Manually edit wifi networks file" off \
  1939. 4 $"Hotspot settings" off \
  1940. 5 $"Exit" on 2> $data
  1941. sel=$?
  1942. case $sel in
  1943. 1) break;;
  1944. 255) break;;
  1945. esac
  1946. case $(cat $data) in
  1947. 1) wifi_enable;;
  1948. 2) wifi_settings;;
  1949. 3) wifi_edit_networks;;
  1950. 4) hotspot_settings;;
  1951. 5) break;;
  1952. esac
  1953. done
  1954. }
  1955. function menu_app_settings {
  1956. detect_installable_apps
  1957. applist=""
  1958. appnames=()
  1959. n=1
  1960. app_index=0
  1961. for a in "${APPS_AVAILABLE[@]}"
  1962. do
  1963. if [[ ${APPS_INSTALLED[$app_index]} != "0" ]]; then
  1964. if [[ $(function_exists configure_interactive_${a}) == "1" ]]; then
  1965. applist="$applist $n $a off"
  1966. n=$[n+1]
  1967. appnames+=("$a")
  1968. fi
  1969. fi
  1970. app_index=$[app_index+1]
  1971. done
  1972. if [ $n -le 1 ]; then
  1973. return
  1974. fi
  1975. backstr=$'Exit'
  1976. applist="$applist $n $backstr on"
  1977. appnames+=("Exit")
  1978. choice=$(dialog --stdout --backtitle $"Freedombone" \
  1979. --title $"Change settings for an App" \
  1980. --radiolist $'Choose:' \
  1981. 26 40 30 $applist)
  1982. if [ $? -eq 0 ]; then
  1983. app_index=$[choice-1]
  1984. chosen_app=${appnames[$app_index]}
  1985. if [[ $chosen_app != "Exit" ]]; then
  1986. configure_interactive_${chosen_app}
  1987. fi
  1988. fi
  1989. }
  1990. function menu_top_level {
  1991. while true
  1992. do
  1993. data=$(tempfile 2>/dev/null)
  1994. trap "rm -f $data" 0 1 2 5 15
  1995. dialog --backtitle $"Freedombone Control Panel" \
  1996. --title $"Control Panel" \
  1997. --radiolist $"Choose an operation:" 29 70 21 \
  1998. 1 $"About this system" off \
  1999. 2 $"Passwords" off \
  2000. 3 $"Backup and Restore" off \
  2001. 4 $"Show Firewall" off \
  2002. 5 $"Verify Tripwire Code" off \
  2003. 6 $"Reset Tripwire" off \
  2004. 7 $"App Settings" off \
  2005. 8 $"Add/Remove Apps" off \
  2006. 9 $"Logging on/off" off \
  2007. 10 $"Ping enable/disable" off \
  2008. 11 $"Manage Users" off \
  2009. 12 $"Email Menu" off \
  2010. 13 $"Domain or User Blocking" off \
  2011. 14 $"Security Settings" off \
  2012. 15 $"Change the name of this system" off \
  2013. 16 $"Set a static local IP address" off \
  2014. 17 $"Wifi menu" off \
  2015. 18 $"Check for updates" off \
  2016. 19 $"Power off the system" off \
  2017. 20 $"Restart the system" off \
  2018. 21 $"Exit" on 2> $data
  2019. sel=$?
  2020. case $sel in
  2021. 1) exit 1;;
  2022. 255) exit 1;;
  2023. esac
  2024. please_wait
  2025. case $(cat $data) in
  2026. 1) show_about;;
  2027. 2) view_or_change_passwords;;
  2028. 3) menu_backup_restore;;
  2029. 4) show_firewall;;
  2030. 5) show_tripwire_verification_code
  2031. any_key_verify;;
  2032. 6) reset_tripwire;;
  2033. 7) menu_app_settings;;
  2034. 8) /usr/local/bin/addremove
  2035. if [ ! "$?" = "0" ]; then
  2036. any_key
  2037. fi
  2038. ;;
  2039. 9) logging_on_off;;
  2040. 10) ping_enable_disable;;
  2041. 11) menu_users;;
  2042. 12) menu_email;;
  2043. 13) domain_blocking;;
  2044. 14) security_settings;;
  2045. 15) change_system_name;;
  2046. 16) set_static_IP;;
  2047. 17) menu_wifi;;
  2048. 18) check_for_updates;;
  2049. 19) shut_down_system;;
  2050. 20) restart_system;;
  2051. 21) break;;
  2052. esac
  2053. done
  2054. }
  2055. if [ ! -f $COMPLETION_FILE ]; then
  2056. echo $'This command should only be run on an installed Freedombone system'
  2057. exit 1
  2058. fi
  2059. ADMIN_USER=$(get_completion_param "Admin user")
  2060. menu_top_level
  2061. clear
  2062. cat /etc/motd
  2063. exit 0