-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created reinstall script, and install-status
- Loading branch information
Showing
9 changed files
with
189 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/ | ||
baseurl=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/ | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key | ||
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/repodata/repomd.xml.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,108 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
set -euo pipefail | ||
|
||
source /usr/local/bin/k4all-utils | ||
# Function to display the help message | ||
show_help() { | ||
echo "Usage: $0 [OPTIONS]" | ||
echo | ||
echo "This script resets the Kubernetes setup by removing specific done files and rebooting the system." | ||
echo | ||
echo "Options:" | ||
echo " --network Delete the /opt/k4all/setup-ph2.done file (related to network configuration)." | ||
echo " --kubernetes Delete the /opt/k4all/k8s-setup-init.done file (related to Kubernetes initialization)." | ||
echo " --hostname Delete the /opt/k4all/setup-hostname.done file (related to Hostname)." | ||
echo " --help Show this help message and exit." | ||
echo | ||
echo "WARNING: Reinstalling the cluster could be dangerous if several modifications have been made." | ||
} | ||
|
||
NET_DEV=$(get_network_device) | ||
mv -f "/etc/NetworkManager/system-connections/${NET_DEV}.nmconnection.backup" "/etc/NetworkManager/system-connections/${NET_DEV}.nmconnection" | ||
# Function to display a warning and ask for user confirmation | ||
ask_for_confirmation() { | ||
echo "WARNING: Reinstalling the cluster could be dangerous if several modifications have been made." | ||
echo "This action may result in data loss or misconfiguration. Do you want to proceed? (yes/no)" | ||
read -r confirmation | ||
if [[ "$confirmation" != "yes" ]]; then | ||
echo "Aborted by user." | ||
exit 0 | ||
fi | ||
} | ||
|
||
rm -rf /opt/k4all/*.done | ||
systemctl reboot | ||
# Initialize flag variables | ||
network_flag=false | ||
kubernetes_flag=false | ||
hostname_flag=false | ||
|
||
# Parse command-line options | ||
for arg in "$@"; do | ||
case $arg in | ||
--network) | ||
network_flag=true | ||
shift | ||
;; | ||
--kubernetes) | ||
kubernetes_flag=true | ||
shift | ||
;; | ||
--hostname) | ||
hostname_flag=true | ||
shift | ||
;; | ||
--help) | ||
show_help | ||
exit 0 | ||
;; | ||
*) | ||
echo "Unknown option: $arg" | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Ask for confirmation before proceeding | ||
ask_for_confirmation | ||
|
||
# Delete all other *.done files except the ones specifically handled by flags | ||
for file in /opt/k4all/*.done; do | ||
if [[ "$file" != "/opt/k4all/setup-ph3.done" && "$file" != "/opt/k4all/setup-ph2.done" && "$file" != "/opt/k4all/k8s-setup-init.done" && "$file" != "/opt/k4all/setup-hostname.done" ]]; then | ||
echo "Deleting $file" | ||
rm -f "$file" | ||
fi | ||
done | ||
|
||
# Delete specific files based on flags | ||
if [ "$network_flag" = true ]; then | ||
if [ -f "/opt/k4all/setup-ph2.done" ]; then | ||
echo "Deleting /opt/k4all/setup-ph2.done" | ||
rm -f /opt/k4all/setup-ph2.done | ||
else | ||
echo "/opt/k4all/setup-ph2.done does not exist" | ||
fi | ||
if [ -f "/opt/k4all/setup-ph3.done" ]; then | ||
echo "Deleting /opt/k4all/setup-ph3.done" | ||
rm -f /opt/k4all/setup-ph3.done | ||
else | ||
echo "/opt/k4all/setup-ph3.done does not exist" | ||
fi | ||
fi | ||
|
||
if [ "$kubernetes_flag" = true ]; then | ||
if [ -f "/opt/k4all/k8s-setup-init.done" ]; then | ||
echo "Deleting /opt/k4all/k8s-setup-init.done" | ||
rm -f /opt/k4all/k8s-setup-init.done | ||
else | ||
echo "/opt/k4all/k8s-setup-init.done does not exist" | ||
fi | ||
fi | ||
|
||
if [ "$hostname_flag" = true ]; then | ||
if [ -f "/opt/k4all/setup-hostname.done" ]; then | ||
echo "Deleting /opt/k4all/setup-hostname.done" | ||
rm -f /opt/k4all/setup-hostname.done | ||
else | ||
echo "/opt/k4all/setup-hostname.done does not exist" | ||
fi | ||
fi | ||
|
||
# Reboot the system | ||
systemctl reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters