-
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.
Merge pull request #23 from panglars/pr
Add openkylin test script and interrupted more metadata echo error
- Loading branch information
Showing
73 changed files
with
3,587 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/target | ||
*report.json | ||
/reports.json | ||
/summary.md |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="apache2" | ||
PACKAGE_VERSION=$(dpkg -l | grep $PACKAGE_NAME | head -n 1 | awk '{print $3}') | ||
PACKAGE_PRETTY_NAME="Apache HTTP Server" | ||
PACKAGE_TYPE="Web Server" | ||
PACKAGE_DESCRIPTION="Apache HTTP Server" | ||
|
||
echo $PACKAGE_VERSION | ||
echo $PACKAGE_PRETTY_NAME | ||
echo $PACKAGE_TYPE | ||
echo $PACKAGE_DESCRIPTION |
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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="apache2" | ||
APACHE_CONF_FILE="/etc/apache2/ports.conf" | ||
DEFAULT_PORT=80 | ||
|
||
# 检查端口是否被占用 | ||
is_port_in_use() { | ||
local port=$1 | ||
netstat -tuln | grep -q ":${port} " | ||
return $? | ||
} | ||
|
||
# 找到一个随机的可用端口 | ||
find_available_port() { | ||
local port | ||
while true; do | ||
port=$((RANDOM % 65535 + 1024)) | ||
if ! is_port_in_use $port; then | ||
echo $port | ||
return | ||
fi | ||
done | ||
} | ||
|
||
# 更新 Apache 配置使用新的端口 | ||
update_apache_port() { | ||
local new_port=$1 | ||
sed -i "s/Listen $DEFAULT_PORT/Listen $new_port/" $APACHE_CONF_FILE | ||
return $? | ||
} | ||
|
||
# 检查 Apache 服务是否正在运行 | ||
is_apache_active() { | ||
systemctl is-active --quiet apache2 | ||
return $? | ||
} | ||
|
||
# 检查 Apache 服务是否启用 | ||
is_apache_enabled() { | ||
systemctl is-enabled --quiet apache2 | ||
return $? | ||
} | ||
|
||
# 检查包是否安装 | ||
is_package_installed() { | ||
dpkg -l | grep -qw $PACKAGE_NAME | ||
return $? | ||
} | ||
|
||
# 安装 Apache 包 | ||
install_apache_package() { | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get update | ||
apt-get install -y $PACKAGE_NAME | ||
return $? | ||
} | ||
|
||
# 主函数逻辑 | ||
main() { | ||
if is_package_installed; then | ||
echo "Package $PACKAGE_NAME is installed." | ||
else | ||
echo "Package $PACKAGE_NAME is not installed. Attempting to install..." | ||
if install_apache_package; then | ||
echo "Package $PACKAGE_NAME installed successfully." | ||
else | ||
echo "Failed to install package $PACKAGE_NAME." | ||
return 1 | ||
fi | ||
fi | ||
|
||
PACKAGE_VERSION=$(dpkg -l | grep $PACKAGE_NAME | head -n 1 | awk '{print $3}') | ||
initial_state_active=$(is_apache_active; echo $?) | ||
initial_state_enabled=$(is_apache_enabled; echo $?) | ||
|
||
if is_apache_active; then | ||
echo "Apache service is running." | ||
exit_status=0 | ||
else | ||
echo "Apache service is not running." | ||
if is_port_in_use $DEFAULT_PORT; then | ||
echo "Port $DEFAULT_PORT is in use. Finding a new port..." | ||
new_port=$(find_available_port) | ||
echo "Configuring Apache to use port $new_port..." | ||
update_apache_port $new_port | ||
fi | ||
|
||
systemctl start apache2 | ||
if is_apache_active; then | ||
echo "Apache service started successfully." | ||
exit_status=0 | ||
else | ||
echo "Failed to start Apache service." | ||
exit_status=1 | ||
fi | ||
fi | ||
|
||
if [ "$initial_state_active" -eq 0 ]; then | ||
systemctl start apache2 | ||
else | ||
systemctl stop apache2 | ||
fi | ||
|
||
if [ "$initial_state_enabled" -eq 0 ]; then | ||
systemctl enable apache2 | ||
else | ||
systemctl disable apache2 | ||
fi | ||
|
||
echo "Apache service state has been restored." | ||
} | ||
|
||
# 执行主函数 | ||
main | ||
|
||
return $exit_status |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="clang" | ||
PACKAGE_VERSION=$(clang --version | grep -oP "version\W?\K.*") | ||
PACKAGE_PRETTY_NAME="Clang C/C++ Compiler" | ||
PACKAGE_TYPE="Compiler Toolchain" | ||
PACKAGE_DESCRIPTION="Clang C/C++ compiler, based on LLVM" | ||
|
||
echo $PACKAGE_VERSION | ||
echo $PACKAGE_PRETTY_NAME | ||
echo $PACKAGE_TYPE | ||
echo $PACKAGE_DESCRIPTION |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
# 检查并安装clang | ||
check_and_install_clang() { | ||
if ! command -v clang &> /dev/null; then | ||
echo "clang not found. Attempting to install..." | ||
if command -v apt-get &> /dev/null; then | ||
export DEBIAN_FRONTEND=noninteractive # 防止apt-get交互式安装 | ||
apt-get install -y clang | ||
elif command -v yum &> /dev/null; then | ||
yum install -y clang | ||
elif command -v dnf &> /dev/null; then | ||
dnf install -y clang | ||
elif command -v zypper &> /dev/null; then | ||
zypper install -y clang | ||
elif command -v pacman &> /dev/null; then | ||
pacman -S --noconfirm clang | ||
else | ||
echo "Unable to install clang. Please install it manually." | ||
return 1 | ||
fi | ||
fi | ||
} | ||
|
||
# 执行检查和安装 | ||
check_and_install_clang | ||
|
||
# 创建一个简单的C程序 | ||
cat << EOF > test.c | ||
#include <stdio.h> | ||
int main() { | ||
printf("Hello, World!\n"); | ||
return 0; | ||
} | ||
EOF | ||
|
||
# 使用clang编译程序 | ||
clang test.c -o test_program | ||
|
||
# 检查编译是否成功 | ||
if [ $? -eq 0 ]; then | ||
exit_status=0 | ||
else | ||
exit_status=1 | ||
fi | ||
|
||
# 运行编译后的程序 | ||
./test_program | ||
|
||
# 清理临时文件 | ||
rm test.c test_program | ||
|
||
PACKAGE_VERSION=$(clang --version | grep -oP "version\W?\K.*") | ||
|
||
return $exit_status |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="cmake" | ||
PACKAGE_VERSION=$(cmake --version | head -n1 | cut -d' ' -f3) | ||
PACKAGE_PRETTY_NAME="CMake" | ||
PACKAGE_TYPE="Build System" | ||
PACKAGE_DESCRIPTION="Cross-platform make" | ||
|
||
echo $PACKAGE_VERSION | ||
echo $PACKAGE_PRETTY_NAME | ||
echo $PACKAGE_TYPE | ||
echo $PACKAGE_DESCRIPTION |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Check if cmake is installed, if not, install it | ||
if ! command -v cmake &> /dev/null; then | ||
echo "CMake is not installed. Installing..." | ||
if [ -x "$(command -v apt-get)" ]; then | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get update | ||
apt-get install -y cmake | ||
elif [ -x "$(command -v yum)" ]; then | ||
yum install -y cmake | ||
elif [ -x "$(command -v dnf)" ]; then | ||
dnf install -y cmake | ||
else | ||
echo "Unable to install CMake. Please install it manually." | ||
return 1 | ||
fi | ||
fi | ||
|
||
PACKAGE_VERSION=$(cmake --version | head -n1 | cut -d' ' -f3) | ||
CURRENT_DIR=$(pwd) | ||
|
||
# Setup temporary test directory | ||
TEMP_DIR="/tmp/cmake_test_dir" | ||
mkdir -p "$TEMP_DIR" | ||
echo "cmake_minimum_required(VERSION 3.10)" > "$TEMP_DIR/CMakeLists.txt" | ||
echo "project(TestProject)" >> "$TEMP_DIR/CMakeLists.txt" | ||
echo "add_executable(test_app main.cpp)" >> "$TEMP_DIR/CMakeLists.txt" | ||
echo 'int main() { return 0; }' > "$TEMP_DIR/main.cpp" | ||
|
||
# Run cmake and make to compile the test project | ||
cd "$TEMP_DIR" && cmake . && make | ||
|
||
# Check if cmake and make succeeded | ||
if [ -f "$TEMP_DIR/test_app" ]; then | ||
if "$TEMP_DIR/test_app"; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
else | ||
return 1 | ||
fi | ||
|
||
cd "$CURRENT_DIR" | ||
|
||
# Cleanup | ||
# rm -rf "$TEMP_DIR" |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
testing_type = "remote" | ||
skip_packages = ["docker"] | ||
|
||
[connection] | ||
method = "ssh" | ||
ip = "localhost" | ||
port = 22 | ||
username = "openkylin" | ||
password = "openkylin" |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="docker-ce" | ||
PACKAGE_VERSION=$(dpkg -l | grep $PACKAGE_NAME | head -n 1 | awk '{print $3}') | ||
PACKAGE_PRETTY_NAME="Docker Engine - Community Edition" | ||
PACKAGE_TYPE="Container Platform" | ||
PACKAGE_DESCRIPTION="Docker Engine - Community Edition" | ||
|
||
echo $PACKAGE_VERSION | ||
echo $PACKAGE_PRETTY_NAME | ||
echo $PACKAGE_TYPE | ||
echo $PACKAGE_DESCRIPTION |
Oops, something went wrong.