|
Server IP : 80.80.81.74 / Your IP : 80.80.80.28 Web Server : Apache/2.4.37 (Oracle Linux Server) System : Linux ust-wp4-prod 5.15.0-310.184.5.2.el8uek.x86_64 #2 SMP Wed Jul 9 16:08:33 PDT 2025 x86_64 User : apache ( 48) PHP Version : 8.4.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0555) : /sbin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
#!/bin/bash
#
# Copyright (c) 2021, 2022 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
#
# alx
. /usr/lib/alx-utils/functions
usage() {
cat >&2 << EOF
Usage: ${0##*/} [OPTION]...
help - Show this message
init - Initialize Oracle Autnomous Linux
validate - Validate Oracle Autonomous Linux
version - Show version
show - Show Oracle Autonomous Linux details, allowed values:
instance_id
compartment_id
realm_key
os_family
os_arch
os_version
reboot_required
osms_ready
enabled_yum_repos
used_yum_repos
ksplice_effective_kernel_version|kekv
known_exploit_detection|ked
clear - Clear message history, allowed values:
known_exploit_detection|ked
EOF
}
do_init() {
run_as_root_check
acquire_lock 30
log "Initializing Oracle Autonomous Linux."
# boot time initialization
if [ "$1" = "--boot" ]; then
# clear migrated file if instance id has changed
if [ -f /var/lib/alx-migrate/migrated ]; then
instance_id=$(get_instance_id)
[ "$instance_id" != "$(cat /var/lib/alx-migrate/migrated)" ] &&
rm -rf /var/lib/alx-migrate/migrated \
/var/lib/alx-migrate/migrate \
/var/lib/alx-migrate/migration
fi
# Create yum uuid file if it doesn't exist
if [ "$OL_VERSION" = 7 ] && [ ! -f /var/lib/yum/uuid ]; then
local uuid=$(uuidgen)
echo -n "$uuid" > /var/lib/yum/uuid
fi
fi
# Fix file /var/lib/yum/uuid permissions - 644
if [ "$OL_VERSION" = 7 ] && [ -f /var/lib/yum/uuid ]; then
if [ "$(stat -c '%a' /var/lib/yum/uuid 2>/dev/null)" != 644 ]; then
chmod 644 /var/lib/yum/uuid
fi
fi
# Disable ksplice autoinstall as ksplice updates install is done by OSMS SJ
is_ksplice_autoinstall_disabled || disable_ksplice_autoinstall
# Set ksplice access key for AL only
is_ksplice_access_key_set || set_ksplice_access_key
# OSMS/OSMH: add or remove OSMS userspace ksplice yum repo
is_userspace_ksplice_yum_repo_set || set_userspace_ksplice_yum_repo
# Enable known exploit detection
is_known_exploit_detection_enabled || enable_known_exploit_detection
# Set vmcore save path in kdump.conf
is_kdump_vmcore_path_set || set_kdump_vmcore_path
# Set DeleteUploaded = yes in /etc/abrt/abrt.conf
# Set CopyVMcore = no in /etc/abrt/plugins/vmcore.conf
# optimize sosreport cmd
is_abrt_configured || configure_abrt
# set OSWatcher maximum age to 12 hours
is_oswatcher_configured || configure_oswatcher
# create oops fifos
are_oops_fifos_created || create_oops_fifos
# Set yum/dnf installonly_limit to 2
is_installonly_limit_set || set_installonly_limit
# attempt to activate know exploit detection
is_known_exploit_detection_activated || activate_known_exploit_detection
log "Initialized Oracle Autonomous Linux."
}
# undo init
do_restore() {
# restore uptrack.conf
is_osms_userspace_ksplice_yum_repo_set &&
unset_osms_userspace_ksplice_yum_repo
}
do_validate() {
run_as_root_check
# mandatory tasks on every check-in
# Disable ksplice autoinstall as ksplice updates install is done by OSMS SJ
is_ksplice_autoinstall_disabled || disable_ksplice_autoinstall
# attempt to activate known exploit detection
is_known_exploit_detection_activated || activate_known_exploit_detection
log "Validating Oracle Autonomous Linux configuration."
(is_osmh_enabled || is_osms_ready) &&
is_ksplice_access_key_set &&
is_ksplice_autoinstall_disabled &&
is_userspace_ksplice_yum_repo_set &&
is_known_exploit_detection_enabled &&
is_kdump_vmcore_path_set &&
is_abrt_configured &&
is_oswatcher_configured &&
are_oops_fifos_created &&
is_installonly_limit_set
local ret=$?
if [ "$ret" -eq 0 ]; then
log "Validated."
else
log_error "Validation failed."
fi
return $ret
}
do_report() {
local what=$1
case "$what" in
"known_exploit_detection"|"ked")
run_as_root_check
local op=$2
if [ "$op" = "--start" ]; then
start_known_exploit_detection_report
elif [ "$op" == "--end" ]; then
end_known_exploit_detection_report
else
usage
fi
;;
*)
usage
;;
esac
}
do_clear() {
local what=$1
case "$what" in
"known_exploit_detection"|"ked")
run_as_root_check
clear_known_exploit_detection_history
;;
*)
usage
;;
esac
}
show_all() {
echo "Instance ID: $(get_instance_id)"
echo "Compartment ID: $(get_compartment_id)"
echo "Realm Key: $(get_realm_key)"
echo "OS Family: $(get_os_family)"
echo "OS Architecture: $(get_os_arch)"
echo "OS Version: $(get_os_version)"
echo "Ksplice Effective Kernel Version: $(get_ksplice_effective_kernel_version)"
if is_reboot_required; then
echo "Reboot Required: yes"
else
echo "Reboot Required: no"
fi
# OSMH
if is_osmh_enabled; then
echo "OS Management Hub enabled: yes"
if is_autonomous_linux_instance; then
echo "Oracle Autonomous Linux enabled: yes"
else
echo "Oracle Autonomous Linux enabled: no"
fi
# OSMS
else
if is_osms_ready; then
echo "OSMS ready: yes"
else
echo "OSMS ready: no"
fi
echo
echo "Enabled Yum Repositories:"
list_enabled_yum_repos || log_error "OSMS is not ready."
fi
}
do_show() {
local what=$1
case "$what" in
"instance_id")
echo "$(get_instance_id)"
;;
"compartment_id")
echo "$(get_compartment_id)"
;;
"realm_key")
echo "$(get_realm_key)"
;;
"os_family")
echo "$(get_os_family)"
;;
"os_arch")
echo "$(get_os_arch)"
;;
"os_version")
echo "$(get_os_version)"
;;
"ksplice_effective_kernel_version"|"kekv")
echo "$(get_ksplice_effective_kernel_version)"
;;
"reboot_required")
run_as_root_check
if is_reboot_required; then
echo "yes"
else
echo "no"
fi
;;
"known_exploit_detection"|"ked")
run_as_root_check
get_known_exploit_detection
;;
"osms_ready")
if is_osms_ready; then
echo "yes"
else
echo "no"
fi
;;
"enabled_yum_repos")
if is_osmh_enabled; then
echo "Not supported."
else
run_as_root_check
list_enabled_yum_repos
ret=$?
if [ $ret -ne 0 ]; then
echo "OSMS is not ready." >&2
fi
return $ret
fi
;;
"used_yum_repos")
list_used_yum_repos || echo "Yum error." >&2
;;
"migrated") #hidden
run_as_root_check
[ -f /var/lib/alx-migrate/migrated ] && echo "yes" || echo "no"
;;
"migration") #hidden
run_as_root_check
get_migration_status
;;
"all"|"")
run_as_root_check
show_all
;;
*)
usage
;;
esac
}
show_version () {
local rpm_version
rpm_version=$(rpm -q --queryformat "%{VERSION}-%{RELEASE}" alx-utils \
2>/dev/null)
if [ $? -eq 0 -a -n "$rpm_version" ]; then
echo "$rpm_version" | sed 's/.el[789]$//'
else
echo "$version"
fi
}
subcmd=$1
shift
case "$subcmd" in
"init")
do_init $*
;;
"show")
do_show $*
;;
"validate")
do_validate $*
;;
"report")
do_report $*
;;
"clear")
do_clear $*
;;
"restore")
do_restore $*
;;
"version")
show_version
;;
*)
usage
;;
esac