Skip to content

Commit

Permalink
Resolved multiple unexistent file error
Browse files Browse the repository at this point in the history
* Resolved a big issue in switch command if prime_logfile not exists, file check added
* Added non existent file handling in various parts of script (next-boot, log-view, unset, current_check)
Those issues manifested themselves after a fresh installation, because some config files still were not present
  • Loading branch information
simopil committed Jan 31, 2019
1 parent 547c5b1 commit 5152d6e
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions prime-select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ function apply_current {
}

function current_check {
if [ "$type" = "$(cat /etc/prime/current_type)" ]; then
if ! [ -f /etc/prime/current_type ]; then
echo "Preparing first configuration"
elif [ "$type" = "$(cat /etc/prime/current_type)" ]; then
echo "$type driver already in use!"
exit
fi
Expand All @@ -207,9 +209,12 @@ case $type in

check_root
current_check
if ! [ -f /var/log/prime-select.log ]; then
echo "##SUSEPrime logfile##" > $prime_logfile
fi
if [ $(wc -l < $prime_logfile) -gt 1000 ]; then
#cleaning logfile if has more than 1k events
rm $prime_logfile
rm $prime_logfile &> /dev/null
echo "##SUSEPrime logfile##" > $prime_logfile
fi
if [ "$type" = "intel2" ];then
Expand Down Expand Up @@ -273,8 +278,12 @@ case $type in

abort)

rm /etc/prime/forced_boot
echo "Next boot forcing aborted"
if [ -f /etc/prime/forced_boot ]; then
rm /etc/prime/forced_boot
echo "Next boot forcing aborted"
else
echo "Next boot is NOT forced"
fi
;;

*)
Expand Down Expand Up @@ -302,10 +311,10 @@ case $type in
check_root
$0 service disable
clean_files
rm /etc/prime/current_type
rm /etc/prime/boot_state
rm /etc/prime/boot
rm /etc/prime/forced_boot
rm /etc/prime/current_type &> /dev/null
rm /etc/prime/boot_state &> /dev/null
rm /etc/prime/boot &> /dev/null
rm /etc/prime/forced_boot &> /dev/null
rm $prime_logfile
;;

Expand Down Expand Up @@ -411,7 +420,11 @@ case $type in

log-view)

less +G -e $prime_logfile
if [ -f $prime_logfile ]; then
less +G -e $prime_logfile
else
echo "No logfile in /var/log/prime-select.log"
fi
;;

log-clean)
Expand Down

0 comments on commit 5152d6e

Please sign in to comment.