mirror of
https://github.com/nextcloud/vm.git
synced 2025-10-26 11:27:32 +00:00
create startup_configuration.sh (#1423)
This commit is contained in:
parent
941e6e7ba3
commit
46f219971c
@ -22,6 +22,7 @@ choice=$(whiptail --title "$TITLE" --menu "Choose what you want to do.\n$MENU_GU
|
||||
"Additional Apps" "(Choose which apps to install)" \
|
||||
"Nextcloud Configuration" "(Choose between available Nextcloud configurations)" \
|
||||
"Server Configuration" "(Choose between available server configurations)" \
|
||||
"Startup Configuration" "(Choose between available startup configurations)" \
|
||||
"Update Nextcloud" "(Update Nextcloud to the latest release)" 3>&1 1>&2 2>&3)
|
||||
|
||||
case "$choice" in
|
||||
@ -37,6 +38,10 @@ case "$choice" in
|
||||
print_text_in_color "$ICyan" "Downloading the Server Configuration script..."
|
||||
run_script MENU server_configuration
|
||||
;;
|
||||
"Startup Configuration")
|
||||
print_text_in_color "$ICyan" "Downloading the Startup Configuration script..."
|
||||
run_script MENU startup_configuration
|
||||
;;
|
||||
"Update Nextcloud")
|
||||
if [ -f $SCRIPTS/update.sh ]
|
||||
then
|
||||
|
||||
105
menu/startup_configuration.sh
Normal file
105
menu/startup_configuration.sh
Normal file
@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/
|
||||
|
||||
# shellcheck disable=2034,2059
|
||||
true
|
||||
SCRIPT_NAME="Startup Configuration Menu"
|
||||
# shellcheck source=lib.sh
|
||||
. <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||
|
||||
# Check for errors + debug code and abort if something isn't right
|
||||
# 1 = ON
|
||||
# 0 = OFF
|
||||
DEBUG=0
|
||||
debug_mode
|
||||
|
||||
# Must be root
|
||||
root_check
|
||||
|
||||
# Get the correct keyboard layout switch
|
||||
if [ "$KEYBOARD_LAYOUT" = "us" ]
|
||||
then
|
||||
KEYBOARD_LAYOUT_SWITCH="ON"
|
||||
else
|
||||
KEYBOARD_LAYOUT_SWITCH="OFF"
|
||||
fi
|
||||
|
||||
# Get the correct timezone switch
|
||||
if [ "$(cat /etc/timezone)" = "Etc/UTC" ]
|
||||
then
|
||||
TIMEZONE_SWITCH="ON"
|
||||
else
|
||||
TIMEZONE_SWITCH="OFF"
|
||||
fi
|
||||
|
||||
# Show a msg_box during the startup script
|
||||
if [ -f "$SCRIPTS/nextcloud-startup-script.sh" ]
|
||||
then
|
||||
msg_box "Running a server, it's important that certain things are correct.
|
||||
In the following menu you will be asked to setup the most basic stuff of your server.
|
||||
|
||||
The script is smart, and have already pre-selected the values that you'd want to change based on the current settings."
|
||||
fi
|
||||
|
||||
# Startup configurations
|
||||
choice=$(whiptail --title "$TITLE" --checklist "Choose what you want to change.\n$CHECKLIST_GUIDE\n$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
|
||||
"Keyboard Layout" "(Change the keyboard layout from '$KEYBOARD_LAYOUT')" "$KEYBOARD_LAYOUT_SWITCH" \
|
||||
"Timezone" "(Change the timezone from $(cat /etc/timezone))" "$TIMEZONE_SWITCH" \
|
||||
"Locate Mirror" "(Change the apt-mirror for faster updates)" OFF 3>&1 1>&2 2>&3)
|
||||
|
||||
case "$choice" in
|
||||
*"Keyboard Layout"*)
|
||||
clear
|
||||
msg_box "Current keyboard layout is $KEYBOARD_LAYOUT."
|
||||
if ! yesno_box_yes "Do you want to change keyboard layout?"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Not changing keyboard layout..."
|
||||
sleep 1
|
||||
clear
|
||||
else
|
||||
dpkg-reconfigure keyboard-configuration
|
||||
setupcon --force
|
||||
# Set locales
|
||||
if ! [ -f "$SCRIPTS/nextcloud-startup-script.sh" ]
|
||||
then
|
||||
run_script ADDONS locales
|
||||
fi
|
||||
input_box "Please try out all buttons (e.g: @ # \$ : y n) to find out if the keyboard settings were correctly applied.\nIf the keyboard is still wrong, you will be offered to reboot the server in the next step.\n\nPlease continue by hitting [ENTER]" >/dev/null
|
||||
if ! yesno_box_yes "Did the keyboard work as expected??\n\nIf you choose 'No' the server will be rebooted. After the reboot, please login as usual and run this script again."
|
||||
then
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
;;&
|
||||
*"Timezone"*)
|
||||
clear
|
||||
msg_box "Current timezone is $(cat /etc/timezone)"
|
||||
if ! yesno_box_yes "Do you want to change the timezone?"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Not changing timezone..."
|
||||
sleep 1
|
||||
clear
|
||||
else
|
||||
dpkg-reconfigure tzdata
|
||||
fi
|
||||
# Change timezone in php and logging if the startup script not exists
|
||||
if ! [ -f "$SCRIPTS/nextcloud-startup-script.sh" ]
|
||||
then
|
||||
# Change timezone in PHP
|
||||
sed -i "s|;date.timezone.*|date.timezone = $(cat /etc/timezone)|g" "$PHP_INI"
|
||||
|
||||
# Change timezone for logging
|
||||
occ_command config:system:set logtimezone --value="$(cat /etc/timezone)"
|
||||
clear
|
||||
fi
|
||||
;;&
|
||||
*"Locate Mirror"*)
|
||||
clear
|
||||
print_text_in_color "$ICyan" "Downloading the Locate Mirror script..."
|
||||
run_script ADDONS locate_mirror
|
||||
;;&
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
exit
|
||||
@ -156,35 +156,14 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Nextcloud 18 is required
|
||||
lowest_compatible_nc 18
|
||||
|
||||
# Import if missing and export again to import it with UUID
|
||||
zpool_import_if_missing
|
||||
|
||||
# Set keyboard layout, important when changing passwords and such
|
||||
if [ "$KEYBOARD_LAYOUT" = "us" ]
|
||||
then
|
||||
clear
|
||||
msg_box "Current keyboard layout is English (United States)."
|
||||
if ! yesno_box_yes "Do you want to change keyboard layout?"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Not changing keyboard layout..."
|
||||
sleep 1
|
||||
clear
|
||||
else
|
||||
dpkg-reconfigure keyboard-configuration
|
||||
setupcon --force
|
||||
input_box "Please try out all buttons to find out if the keyboard settings were correctly applied.\nIf this isn't the case, you will have the chance to reboot the server in the next step.\n\nPlease continue by hitting [ENTER]" >/dev/null
|
||||
if yesno_box_no "Do you want to reboot the server?\nPlease only choose 'Yes' if the keyboard settings weren't correctly applied.\n\nIf you choose 'Yes' and the server is rebooted, please login as usual and run this script again."
|
||||
then
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set locales
|
||||
run_script ADDONS locales
|
||||
|
||||
# Nextcloud 18 is required
|
||||
lowest_compatible_nc 18
|
||||
# Run the startup menu
|
||||
run_script MENU startup_configuration
|
||||
|
||||
# Is this run as a pure root user?
|
||||
if is_root
|
||||
@ -218,9 +197,6 @@ please abort this script (CTRL+C) and report this issue to $ISSUES."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Upgrade mirrors
|
||||
run_script ADDONS locate_mirror
|
||||
|
||||
######## The first setup is OK to run to this point several times, but not any further ########
|
||||
if [ -f "$SCRIPTS/you-can-not-run-the-startup-script-several-times" ]
|
||||
then
|
||||
@ -333,16 +309,8 @@ When the setup is done, the server will automatically reboot.
|
||||
Please report any issues to: $ISSUES"
|
||||
clear
|
||||
|
||||
# Change Timezone
|
||||
msg_box "Current timezone is $(cat /etc/timezone)"
|
||||
if ! yesno_box_yes "Do you want to change the timezone?"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Not changing timezone..."
|
||||
sleep 1
|
||||
clear
|
||||
else
|
||||
dpkg-reconfigure tzdata
|
||||
fi
|
||||
# Set locales
|
||||
run_script ADDONS locales
|
||||
|
||||
# Change timezone in PHP
|
||||
sed -i "s|;date.timezone.*|date.timezone = $(cat /etc/timezone)|g" "$PHP_INI"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user