-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuyujitaku.sh
More file actions
executable file
·99 lines (81 loc) · 2.04 KB
/
Copy pathfuyujitaku.sh
File metadata and controls
executable file
·99 lines (81 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
. ./lib/functions.sh
#######################################################################
#
# This script is used to enable hibernation.
#
#######################################################################
# ----------------------------------------------------------------------
# Main script starts here.
#
# If it return non zero, abort the script.
check_root_filesystem
if [ $? -ne 0 ]; then
exit 1
fi
set_default_target_swap_size
set_default_hibernate_delay_sec
# If it returns non zeor, abort the script
parse_arguments "$@"
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zeor, abort the script
validate_and_normalize_hibernate_delay_sec
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zeor, abort the script
validate_and_normalize_target_swap_size
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zeor, abort the script
validate_swap_file_size
if [ $? -ne 0 ]; then
exit 1
fi
# Ask user for confirmation before proceeding
echo ""
echo "This script will modify your system configuration to enable hibernation."
echo "The following changes will be made:"
echo " - Resize swap file to ${TARGET_SWAP_SIZE}MB."
echo " - Update GRUB configuration."
echo " - Configure hibernation delay to ${HIBERNATE_DELAY_SEC} seconds."
echo " - Set hibernation policy to allow hibernation from menu."
echo ""
printf "Do you want to continue? (y/N): "
read -r RESPONSE
case "$RESPONSE" in
[yY]|[yY][eE][sS])
echo "Proceeding with hibernation configuration..."
;;
*)
echo "Aborted by user."
exit 0
;;
esac
echo ""
save_original_config
# If it returns non zero, abort the script.
resize_swap_file
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zero, abort the script.
inform_swap_location_to_kernel
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zero, abort the script.
configure_hibernate_delay_sec
if [ $? -ne 0 ]; then
exit 1
fi
# If it returns non zero, abort the script.
configure_hibernation_policy
if [ $? -ne 0 ]; then
exit 1
fi
print_end_message
exit 0