mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
Added journal user quota for sashi users. (#52)
This commit is contained in:
committed by
GitHub
parent
1f7f5fa105
commit
982b93a3d6
6
dependencies/user-install.sh
vendored
6
dependencies/user-install.sh
vendored
@@ -56,7 +56,7 @@ contract_host_uid=$(expr $uoffset + $contract_uid - 1)
|
||||
contract_host_gid=$(expr $goffset + $contract_gid - 1)
|
||||
|
||||
groupadd -g "$contract_host_gid" "$contract_user"
|
||||
useradd --shell /usr/sbin/nologin -M -g "$contract_host_gid" -u "$contract_host_uid" "$contract_user"
|
||||
useradd --shell /usr/sbin/nologin -M -g "$contract_host_gid" -G "$user" -u "$contract_host_uid" "$contract_user"
|
||||
usermod --lock "$contract_user"
|
||||
echo "Created '$contract_user' contract user."
|
||||
|
||||
@@ -71,8 +71,8 @@ dockerd_socket="unix://$user_runtime_dir/docker.sock"
|
||||
echo "${memory}K" >/sys/fs/cgroup/memory/$user$cgroupsuffix/memory.limit_in_bytes &&
|
||||
echo "${memory}K" >/sys/fs/cgroup/memory/$user$cgroupsuffix/memory.memsw.limit_in_bytes) && rollback "CGROUP_MEM_CREAT"
|
||||
|
||||
# Adding disk quota to the new user.
|
||||
setquota -u -F vfsv0 "$user" "$disk" "$disk" 0 0 /
|
||||
# Adding disk quota to the group.
|
||||
setquota -g -F vfsv0 "$user" "$disk" "$disk" 0 0 /
|
||||
|
||||
echo "Configured the resources"
|
||||
|
||||
|
||||
23
prereq.sh
23
prereq.sh
@@ -19,13 +19,24 @@ apt-get update
|
||||
apt install uidmap -y
|
||||
|
||||
# Check for pattern <Not starting with a comment><Not whitespace(Device)><Whitespace></><Whitespace><Not whitespace(FS type)><Whitespace><No whitespace(Options)><Whitespace><Number(Dump)><Whitespace><Number(Pass)>
|
||||
# And whether Options is <Not whitespace>*usrquota<Not whitespace>*
|
||||
# If not add usrquota to the options.
|
||||
# And whether Options is <Not whitespace>*grpjquota=aquota.group or jqfmt=vfsv0<Not whitespace>*
|
||||
# If not add groupquota to the options.
|
||||
updated=0
|
||||
sed -n -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ /^\S+\s+\/\s+\S+\s+\S*usrquota\S*/{q100} }" "$tmpfstab"
|
||||
sed -n -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ /^\S+\s+\/\s+\S+\s+\S*grpjquota=aquota.group\S*/{q100} }" "$tmpfstab"
|
||||
res=$?
|
||||
if [ $res -eq 0 ]; then
|
||||
sed -i -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ s/^\S+\s+\/\s+\S+\s+\S+/&,usrquota/ }" "$tmpfstab"
|
||||
sed -i -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ s/^\S+\s+\/\s+\S+\s+\S+/&,grpjquota=aquota.group/ }" "$tmpfstab"
|
||||
res=$?
|
||||
updated=1
|
||||
fi
|
||||
|
||||
# If the res is not success(0) or alredy exist(100).
|
||||
[ ! $res -eq 0 ] && [ ! $res -eq 100 ] && echo "fstab update failed." && exit 1
|
||||
|
||||
sed -n -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ /^\S+\s+\/\s+\S+\s+\S*jqfmt=vfsv0\S*/{q100} }" "$tmpfstab"
|
||||
res=$?
|
||||
if [ $res -eq 0 ]; then
|
||||
sed -i -r -e "/^[^#]\S+\s+\/\s+\S+\s+\S+\s+[0-9]+\s+[0-9]+\s*/{ s/^\S+\s+\/\s+\S+\s+\S+/&,jqfmt=vfsv0/ }" "$tmpfstab"
|
||||
res=$?
|
||||
updated=1
|
||||
fi
|
||||
@@ -47,8 +58,8 @@ else
|
||||
echo "fstab already configured."
|
||||
fi
|
||||
|
||||
# Check and turn on user quota if not enabled.
|
||||
if [ ! -f /aquota.user ]; then
|
||||
# Check and turn on group quota if not enabled.
|
||||
if [ ! -f /aquota.group ]; then
|
||||
# quota package is not installed.
|
||||
if ! command -v quota &>/dev/null; then
|
||||
apt-get install -y quota
|
||||
|
||||
Reference in New Issue
Block a user