Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build/sysroot/usr/share/casaos/shell/helper.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# 获取系统信息
GetSysInfo() {

Check warning on line 4 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWOx&open=AZ_ObZFJYxMmyirvnWOx&pullRequest=2566
if [ -s "/etc/redhat-release" ]; then

Check failure on line 5 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWOy&open=AZ_ObZFJYxMmyirvnWOy&pullRequest=2566
SYS_VERSION=$(cat /etc/redhat-release)
elif [ -s "/etc/issue" ]; then

Check failure on line 7 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWOz&open=AZ_ObZFJYxMmyirvnWOz&pullRequest=2566
SYS_VERSION=$(cat /etc/issue)
fi
SYS_INFO=$(uname -a)
Expand All @@ -20,7 +20,7 @@
#获取网卡信息
GetNetCard() {
if [ "$1" == "1" ]; then
if [ -d "/sys/devices/virtual/net" ]; then

Check failure on line 23 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWO4&open=AZ_ObZFJYxMmyirvnWO4&pullRequest=2566
ls /sys/devices/virtual/net
fi
else
Expand All @@ -39,12 +39,12 @@
#param 网卡名称
CatNetCardState() {
if [ -e "/sys/class/net/$1/operstate" ]; then
cat /sys/class/net/$1/operstate
cat "/sys/class/net/$1/operstate"
fi
}

#获取docker根目录
GetDockerRootDir() {

Check warning on line 47 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPD&open=AZ_ObZFJYxMmyirvnWPD&pullRequest=2566
if hash docker 2>/dev/null; then
docker info | grep 'Docker Root Dir' | awk -F ':' '{print $2}'
else
Expand All @@ -55,31 +55,31 @@
#删除安装应用文件夹
#param 需要删除的文件夹路径
DelAppConfigDir() {
if [ -d $1 ]; then
rm -fr $1
if [ -d "$1" ]; then

Check failure on line 58 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPG&open=AZ_ObZFJYxMmyirvnWPG&pullRequest=2566
rm -fr "$1"
fi
}

#zerotier本机已加入的网络
#result start,end,sectors
GetLocalJoinNetworks() {

Check warning on line 65 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'GetLocalJoinNetworks' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPJ&open=AZ_ObZFJYxMmyirvnWPJ&pullRequest=2566

Check warning on line 65 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPK&open=AZ_ObZFJYxMmyirvnWPK&pullRequest=2566
zerotier-cli listnetworks -j
}

#格式化fat32磁盘
#param 需要格式化的目录 /dev/sda1
#param 格式
FormatDisk() {

Check warning on line 72 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'FormatDisk' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPL&open=AZ_ObZFJYxMmyirvnWPL&pullRequest=2566
if [ "$2" == "fat32" ]; then

Check warning on line 73 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPO&open=AZ_ObZFJYxMmyirvnWPO&pullRequest=2566
mkfs.vfat -F 32 $1
elif [ "$2" == "ntfs" ]; then
mkfs.ntfs $1
elif [ "$2" == "ext4" ]; then
mkfs.ext4 -m 1 -F $1
elif [ "$2" == "exfat" ]; then

Check warning on line 79 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPX&open=AZ_ObZFJYxMmyirvnWPX&pullRequest=2566
mkfs.exfat $1
else
mkfs.ext4 -m 1 -F $1

Check warning on line 82 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPZ&open=AZ_ObZFJYxMmyirvnWPZ&pullRequest=2566
fi
}

Expand All @@ -87,7 +87,7 @@
#param 路径 /dev/sdb
#param 删除分区的区号
DelPartition() {
fdisk $1 <<EOF

Check warning on line 90 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPc&open=AZ_ObZFJYxMmyirvnWPc&pullRequest=2566
d
$2
wq
Expand All @@ -97,27 +97,27 @@
#添加分区只有一个分区
#param 路径 /dev/sdb
#param 要挂载的目录
AddPartition() {

Check warning on line 100 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'AddPartition' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPd&open=AZ_ObZFJYxMmyirvnWPd&pullRequest=2566

Check warning on line 100 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPe&open=AZ_ObZFJYxMmyirvnWPe&pullRequest=2566

DelPartition $1
parted -s $1 mklabel gpt

Check warning on line 103 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPg&open=AZ_ObZFJYxMmyirvnWPg&pullRequest=2566

parted -s $1 mkpart primary ext4 0 100%

Check warning on line 105 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPh&open=AZ_ObZFJYxMmyirvnWPh&pullRequest=2566
P=`lsblk -r $1 | sort | grep part | head -n 1 | awk '{print $1}'`

Check warning on line 106 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace backticks with '$()' syntax for command substitution.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPi&open=AZ_ObZFJYxMmyirvnWPi&pullRequest=2566
mkfs.ext4 -m 1 -F /dev/${P}

partprobe $1

Check warning on line 109 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPk&open=AZ_ObZFJYxMmyirvnWPk&pullRequest=2566

}

#磁盘类型
GetDiskType() {

Check warning on line 114 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'GetDiskType' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPl&open=AZ_ObZFJYxMmyirvnWPl&pullRequest=2566
fdisk $1 -l | grep Disklabel | awk -F: '{print $2}'
}

#获磁盘的插入路径
#param 路径 /dev/sda
GetPlugInDisk() {

Check warning on line 120 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'GetPlugInDisk' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPo&open=AZ_ObZFJYxMmyirvnWPo&pullRequest=2566
fdisk -l | grep 'Disk' | grep 'sd' | awk -F , '{print substr($1,11,3)}'
}

Expand All @@ -127,19 +127,19 @@
#param 磁盘路径 /dev/sda
#result bytes
#result sectors
GetDiskSizeAndSectors() {

Check warning on line 130 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPr&open=AZ_ObZFJYxMmyirvnWPr&pullRequest=2566
fdisk $1 -l | grep "$1:" | awk -F, 'BEGIN {OFS="\n"}{print $2,$3}' | awk '{print $1}'

Check warning on line 131 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPs&open=AZ_ObZFJYxMmyirvnWPs&pullRequest=2566
}

#获取磁盘分区数据扇区
#param 磁盘路径 /dev/sda
#result start,end,sectors
GetPartitionSectors() {

Check warning on line 137 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPv&open=AZ_ObZFJYxMmyirvnWPv&pullRequest=2566
fdisk $1 -l | grep "$1[1-9]" | awk 'BEGIN{OFS=","}{print $1,$2,$3,$4}'

Check warning on line 138 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPx&open=AZ_ObZFJYxMmyirvnWPx&pullRequest=2566

Check warning on line 138 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPw&open=AZ_ObZFJYxMmyirvnWPw&pullRequest=2566
}

#检查没有使用的挂载点删除文件夹
AutoRemoveUnuseDir() {

Check warning on line 142 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'AutoRemoveUnuseDir' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWPy&open=AZ_ObZFJYxMmyirvnWPy&pullRequest=2566
DIRECTORY="/DATA/"
dir=$(ls -l $DIRECTORY | grep "USB_Storage_sd[a-z][0-9]" | awk '/^d/ {print $NF}')
for i in $dir; do
Expand Down Expand Up @@ -170,7 +170,7 @@
# See if this drive is already mounted, and if so where
MOUNT_POINT=$(lsblk -o name,mountpoint | grep ${DEVICE} | awk '{print $2}')

if [ -n "${MOUNT_POINT}" ]; then

Check failure on line 173 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWP4&open=AZ_ObZFJYxMmyirvnWP4&pullRequest=2566
${log} "Warning: ${DEVICE} is already mounted at ${MOUNT_POINT}"
exit 1
fi
Expand Down Expand Up @@ -220,7 +220,7 @@
}

# $1=sda1
do_umount() {

Check warning on line 223 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWP6&open=AZ_ObZFJYxMmyirvnWP6&pullRequest=2566
log="logger -t usb-mount.sh -s "
DEVBASE=$1
DEVICE="${DEVBASE}"
Expand All @@ -242,12 +242,12 @@
}
# $1=/mnt/volume1/data.img
# $2=100G
PackageDocker() {

Check warning on line 245 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWP-&open=AZ_ObZFJYxMmyirvnWP-&pullRequest=2566
image=$1
docker="/mnt/casa_docker"
#判断目录docker存在不存在则创建,存在检查是否为空

if [ ! -d "$docker" ]; then

Check failure on line 250 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWP_&open=AZ_ObZFJYxMmyirvnWP_&pullRequest=2566
mkdir ${docker}
fi

Expand All @@ -260,7 +260,7 @@

daemon="/etc/docker/daemon.json"
#1创建img文件在挂载的目录
fallocate -l $2 $image

Check warning on line 263 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQB&open=AZ_ObZFJYxMmyirvnWQB&pullRequest=2566
#2初始化img文件
mkfs -t ext4 $image
#3挂载img文件
Expand Down Expand Up @@ -291,7 +291,7 @@
docker info | grep "Docker Root Dir:"
}

SetLink() {

Check warning on line 294 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'SetLink' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQH&open=AZ_ObZFJYxMmyirvnWQH&pullRequest=2566
ln -s /mnt/casa_sda1/AppData /DATA/AppData
#删除所有软链
find /DATA -type l -delete
Expand All @@ -314,7 +314,7 @@
du -sh /DATA
}

USB_Start_Auto() {

Check warning on line 317 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQM&open=AZ_ObZFJYxMmyirvnWQM&pullRequest=2566
((EUID)) && sudo_cmd="sudo"
$sudo_cmd systemctl enable devmon@devmon
$sudo_cmd systemctl start devmon@devmon
Expand All @@ -327,31 +327,31 @@
$sudo_cmd udevil clean
}

GetDeviceTree(){

Check warning on line 330 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQQ&open=AZ_ObZFJYxMmyirvnWQQ&pullRequest=2566
cat /proc/device-tree/model
}

# restart samba service
RestartSMBD(){

Check warning on line 335 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQS&open=AZ_ObZFJYxMmyirvnWQS&pullRequest=2566

Check warning on line 335 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'RestartSMBD' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQR&open=AZ_ObZFJYxMmyirvnWQR&pullRequest=2566
$sudo_cmd systemctl restart smbd
}

# edit user password $1:username
EditSmabaUserPassword(){

Check warning on line 340 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'EditSmabaUserPassword' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQT&open=AZ_ObZFJYxMmyirvnWQT&pullRequest=2566

Check warning on line 340 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQU&open=AZ_ObZFJYxMmyirvnWQU&pullRequest=2566
$sudo_cmd smbpasswd $1
}

AddSmabaUser(){
$sudo_cmd useradd $1
$sudo_cmd smbpasswd -a $1 <<EOF
$sudo_cmd useradd "$1"
$sudo_cmd smbpasswd -a "$1" <<EOF

Check warning on line 346 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQZ&open=AZ_ObZFJYxMmyirvnWQZ&pullRequest=2566
$2
$2
EOF
}

# $1:username $2:host $3:share $4:port $5:mountpoint $6:password
MountCIFS(){

Check warning on line 353 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function 'MountCIFS' should be named in snake case.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQa&open=AZ_ObZFJYxMmyirvnWQa&pullRequest=2566
$sudo_cmd mount -t cifs -o username=$1,password=$6,port=$4 //$2/$3 $5
$sudo_cmd mount -t cifs -o "username=$1,password=$6,port=$4" "//$2/$3" "$5"

Check warning on line 354 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQd&open=AZ_ObZFJYxMmyirvnWQd&pullRequest=2566

Check warning on line 354 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQf&open=AZ_ObZFJYxMmyirvnWQf&pullRequest=2566

Check warning on line 354 in build/sysroot/usr/share/casaos/shell/helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=IceWhaleTech_CasaOS&issues=AZ_ObZFJYxMmyirvnWQc&open=AZ_ObZFJYxMmyirvnWQc&pullRequest=2566
}

UDEVILUmount(){
Expand Down
4 changes: 2 additions & 2 deletions drivers/dropbox/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const ICONURL = "./img/driver/Dropbox.svg"
type Addition struct {
driver.RootID
RefreshToken string `json:"refresh_token" required:"true" omit:"true"`
AppKey string `json:"app_key" type:"string" default:"tciqajyazzdygt9" omit:"true"`
AppSecret string `json:"app_secret" type:"string" default:"e7gtmv441cwdf0n" omit:"true"`
AppKey string `json:"app_key" type:"string" default:"" omit:"true"`
AppSecret string `json:"app_secret" type:"string" default:"" omit:"true"`
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" omit:"true"`
AuthUrl string `json:"auth_url" type:"string" default:""`
Icon string `json:"icon" type:"string" default:"./img/driver/Dropbox.svg"`
Expand Down
8 changes: 4 additions & 4 deletions drivers/dropbox/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

var (
app_key = "private build"
app_secret = "private build"
app_key = ""
app_secret = ""
)

func (d *Dropbox) getRefreshToken() error {
Expand All @@ -29,7 +29,7 @@ func (d *Dropbox) getRefreshToken() error {
if err != nil {
return err
}
logger.Info("get refresh token", zap.String("res", res.String()))
logger.Info("get refresh token", zap.String("status", res.Status()))
if e.Error != "" {
return fmt.Errorf(e.Error)
}
Expand All @@ -50,7 +50,7 @@ func (d *Dropbox) refreshToken() error {
if err != nil {
return err
}
logger.Info("get refresh token", zap.String("res", res.String()))
logger.Info("refresh token", zap.String("status", res.Status()))
if e.Error != "" {
return fmt.Errorf(e.Error)
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/google_drive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
)

var (
client_id = "private build"
client_secret = "private build"
client_id = ""
client_secret = ""
)

// do others that not defined in Driver interface
Expand All @@ -38,7 +38,7 @@ func (d *GoogleDrive) getRefreshToken() error {
if err != nil {
return err
}
logger.Info("get refresh token", zap.String("res", res.String()))
logger.Info("get refresh token", zap.String("status", res.Status()))
if e.Error != "" {
return fmt.Errorf(e.Error)
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/onedrive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

var (
client_id = "private build"
client_secret = "private build"
client_id = ""
client_secret = ""
)

var onedriveHostMap = map[string]Host{
Expand Down Expand Up @@ -81,7 +81,7 @@ func (d *Onedrive) getRefreshToken() error {
if err != nil {
return err
}
logger.Info("get refresh token", zap.String("res", res.String()))
logger.Info("get refresh token", zap.String("status", res.Status()))
if e.Error != "" {
return fmt.Errorf("%s", e.ErrorDescription)
}
Expand All @@ -107,7 +107,7 @@ func (d *Onedrive) _refreshToken() error {
if err != nil {
return err
}
logger.Info("get refresh token", zap.String("res", res.String()))
logger.Info("get refresh token", zap.String("status", res.Status()))
if e.Error != "" {
return fmt.Errorf("%s", e.ErrorDescription)
}
Expand Down
57 changes: 25 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/IceWhaleTech/CasaOS

go 1.21
go 1.25.0

require (
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
Expand All @@ -10,7 +10,7 @@ require (
github.com/deepmap/oapi-codegen v1.12.4
github.com/disintegration/imaging v1.6.2
github.com/dsoprea/go-exif/v3 v3.0.1
github.com/getkin/kin-openapi v0.117.0
github.com/getkin/kin-openapi v0.146.0
github.com/glebarez/sqlite v1.8.0
github.com/go-ini/ini v1.67.0
github.com/go-resty/resty/v2 v2.7.0
Expand All @@ -23,9 +23,9 @@ require (
github.com/h2non/filetype v1.1.3
github.com/hirochachacha/go-smb2 v1.1.0
github.com/json-iterator/go v1.1.12
github.com/labstack/echo/v4 v4.12.0
github.com/labstack/echo-jwt/v4 v4.2.0
github.com/labstack/echo/v4 v4.15.4
github.com/maruel/natural v1.1.0
github.com/mholt/archiver/v3 v3.5.1
github.com/mileusna/useragent v1.2.1
github.com/moby/sys/mount v0.3.3
github.com/moby/sys/mountinfo v0.6.2
Expand All @@ -35,14 +35,14 @@ require (
github.com/samber/lo v1.38.1
github.com/shirou/gopsutil/v3 v3.23.2
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.11.1
github.com/tidwall/gjson v1.17.0
go.uber.org/goleak v1.2.1
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.23.0
golang.org/x/oauth2 v0.7.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.20.0
golang.org/x/crypto v0.54.0
golang.org/x/oauth2 v0.27.0
golang.org/x/sync v0.22.0
golang.org/x/sys v0.47.0
gorm.io/gorm v1.25.0
gotest.tools v2.2.0+incompatible
)
Expand All @@ -61,60 +61,53 @@ require (
github.com/glebarez/go-sqlite v1.21.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/jsonpointer v0.22.5 // indirect
github.com/go-openapi/swag/jsonname v0.25.5 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/safetext v0.0.0-20240104143208-7a7d9b3d812f // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/labstack/echo-jwt/v4 v4.2.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/labstack/gommon v0.5.0 // indirect
github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/perimeterx/marshmallow v1.1.4 // indirect
github.com/oasdiff/yaml v0.1.1 // indirect
github.com/oasdiff/yaml3 v0.0.14 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/ulikunitz/xz v0.5.16 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/image v0.6.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/image v0.44.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/text v0.40.0 // indirect
golang.org/x/time v0.15.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading