Skip to content

Commit b257839

Browse files
committed
[fix] : Fixed user_check func
1 parent 8194eaf commit b257839

File tree

3 files changed

+14
-43
lines changed

3 files changed

+14
-43
lines changed

modules/share/airootfs.any/root/customize_airootfs.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,10 @@ if [[ -f "/etc/skel/Desktop/calamares.desktop" ]]; then
113113
fi
114114

115115

116-
# Creating a root user.
117-
# usermod -s /usr/bin/zsh root
116+
# user_check <name>
118117
function user_check () {
119-
if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
120-
if [[ -z $1 ]]; then
121-
echo -n "false"
122-
fi
123-
echo -n "true"
124-
else
125-
echo -n "false"
126-
fi
118+
if [[ ! -v 1 ]]; then return 2; fi
119+
getent passwd "${1}" > /dev/null
127120
}
128121

129122
# Execute only if the command exists
@@ -163,7 +156,7 @@ function create_user () {
163156
fi
164157
set -u
165158

166-
if [[ $(user_check ${_username}) = false ]]; then
159+
if user_check "${_username}"; then
167160
useradd -m -s ${usershell} ${_username}
168161
groupadd sudo
169162
usermod -U -g ${_username} ${_username}

system/aur.sh

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,17 @@ aur_username="aurbuild"
1212

1313
trap 'exit 1' 1 2 3 15
1414

15-
# Delete file only if file exists
16-
# remove <file1> <file2> ...
17-
function remove () {
18-
local _list
15+
# Show message when file is removed
16+
# remove <file> <file> ...
17+
remove() {
1918
local _file
20-
_list=($(echo "$@"))
21-
for _file in "${_list[@]}"; do
22-
if [[ -f ${_file} ]]; then
23-
rm -f "${_file}"
24-
elif [[ -d ${_file} ]]; then
25-
rm -rf "${_file}"
26-
fi
27-
echo "${_file} was deleted."
28-
done
19+
for _file in "${@}"; do echo "Removing ${_file}" >&2; rm -rf "${_file}"; done
2920
}
3021

3122
# user_check <name>
3223
function user_check () {
33-
if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
34-
if [[ -z $1 ]]; then
35-
echo -n "false"
36-
fi
37-
echo -n "true"
38-
else
39-
echo -n "false"
40-
fi
24+
if [[ ! -v 1 ]]; then return 2; fi
25+
getent passwd "${1}" > /dev/null
4126
}
4227

4328
# Creating a aur user.
@@ -51,8 +36,7 @@ echo "${aur_username} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/aurbuild"
5136

5237
# Setup keyring
5338
pacman-key --init
54-
#eval $(cat "/etc/systemd/system/pacman-init.service" | grep 'ExecStart' | sed "s|ExecStart=||g" )
55-
ls "/usr/share/pacman/keyrings/"*".gpg" | sed "s|.gpg||g" | xargs | pacman-key --populate
39+
pacman-key --populate
5640

5741
# Un comment the mirror list.
5842
#sed -i "s/#Server/Server/g" "/etc/pacman.d/mirrorlist"

system/pkgbuild.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ function remove () {
2929

3030
# user_check <name>
3131
function user_check () {
32-
if [[ -z "${1}" ]]; then
33-
return 1
34-
elif getent passwd "${1}" > /dev/null; then
35-
return 0
36-
else
37-
return 1
38-
fi
32+
if [[ ! -v 1 ]]; then return 2; fi
33+
getent passwd "${1}" > /dev/null
3934
}
4035

4136
# 一般ユーザーで実行します
@@ -62,8 +57,7 @@ echo "${build_username} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/pkgbuild"
6257

6358
# Setup keyring
6459
pacman-key --init
65-
#eval $(cat "/etc/systemd/system/pacman-init.service" | grep 'ExecStart' | sed "s|ExecStart=||g" )
66-
ls "/usr/share/pacman/keyrings/"*".gpg" | sed "s|.gpg||g" | xargs | pacman-key --populate
60+
pacman-key --populate
6761

6862
# Un comment the mirror list.
6963
#sed -i "s/#Server/Server/g" "/etc/pacman.d/mirrorlist"

0 commit comments

Comments
 (0)