Browse Source

fix install.sh no configuration file

main
pvincent 1 week ago
parent
commit
2ff8c373b1
  1. 49
      install.sh

49
install.sh

@ -57,31 +57,35 @@ function compute_cpu_cores {
} }
function choose_default { function choose_default {
echo 'initializing default values...'
storage_size='20G' storage_size='20G'
memory='2G' memory='2G'
swap='2G' swap='2G'
cpu=$(compute_cpu_cores) cpu=$(compute_cpu_cores)
mapfile -t storages <<< $(pvesm status | grep zfspool | cut -d' ' -f1) mapfile -t storages <<< $(pvesm status | grep zfspool | cut -d' ' -f1)
PS3="Choose default storage number: "
echo "TYPE=ZFSPOOL STORAGE LIST:"
echo "--------------------------"
echo "$-"
if [[ ! "$-" =~ i ]]; then if [[ ! "$-" =~ i ]]; then
echo non interactive
# non-interactive, default to first item # non-interactive, default to first item
interactive=false
storage_disk="${storages[0]}" storage_disk="${storages[0]}"
echo "----------------------------------------------------"
echo "first TYPE=ZFSPOOL found: $storage_disk"
echo "to change, please launch one more time: `install.sh`"
echo "----------------------------------------------------"
else else
echo interactive
# interactive, ask for default # interactive, ask for default
interactive=true
PS3="Choose default storage number: "
echo "TYPE=ZFSPOOL STORAGE LIST:"
echo "--------------------------"
select storage_disk in "${storages[@]}"; do select storage_disk in "${storages[@]}"; do
[[ -n $storage_disk ]] && break [[ -n $storage_disk ]] && break
done done
fi fi
cat > $CONFIG_FILE <<EOF
cat > $CONFIG_FILE <<EOF
INTERACTIVE=$interactive
STORAGE_DISK=\${STORAGE_DISK:-$storage_disk} STORAGE_DISK=\${STORAGE_DISK:-$storage_disk}
STORAGE_SIZE=\${STORAGE_SIZE:-$storage_size} STORAGE_SIZE=\${STORAGE_SIZE:-$storage_size}
MEMORY=\${MEMORY:-$memory} MEMORY=\${MEMORY:-$memory}
@ -91,18 +95,19 @@ EOF
} }
function initialize { function initialize {
if [[ ! -d /opt/miaou-proxmox/config ]]; then
echo 'initializing default values...'
mkdir /opt/miaou-proxmox/config
mkdir -p /opt/miaou-proxmox/config
if [[ ! -f $CONFIG_FILE ]] || ! grep -q 'INTERACTIVE=true' $CONFIG_FILE; then
choose_default choose_default
else
echo '------------------------' echo '------------------------'
pct-default
echo 'successfully configured!'
echo '------------------------'
else
echo '------------------------------'
echo 'no change: already configured!'
echo '------------------------------'
fi fi
echo '------------------------'
echo 'successfully configured!'
echo '------------------------'
echo 'you can display or edit default values with:' echo 'you can display or edit default values with:'
echo ' `pct-default`' echo ' `pct-default`'
echo ' `pct-default --edit`' echo ' `pct-default --edit`'
@ -113,10 +118,8 @@ function initialize {
# MAIN # MAIN
set Eue set Eue
# assert_root
# assert_proxmox
# install_miaou_bash
# install_miaou_proxmox
choose_default
#initialize
assert_root
assert_proxmox
install_miaou_bash
install_miaou_proxmox
initialize
Loading…
Cancel
Save