Skip to content

Commit

Permalink
Merge branch 'v99.99' into 'v7.0'
Browse files Browse the repository at this point in the history
minio #99

See merge request toulousain79/MySB!488
  • Loading branch information
toulousain79 committed Oct 1, 2019
2 parents 25793a0 + d4e4798 commit 0fa05f0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions bin/MySB_UpdateTools
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fi

#### rTorrent scripts (to leave for next version ;-)
for sUser in ${gsUsersList}; do
(! grep -q 'rev 0.8' "/etc/init.d/rtorrent-${sUser}") && bRtorrentRestart=1
(! grep -q 'rev 0.9' "/etc/init.d/rtorrent-${sUser}") && bRtorrentRestart=1
(! grep -q 'rev 0.8' /home/${sUser}/.rTorrent_erased.sh) && bRtorrentRestart=1
(! grep -q 'rev 0.8' /home/${sUser}/.rTorrent_finished.sh) && bRtorrentRestart=1
(! grep -q 'rev 0.8' /home/${sUser}/.rTorrent_inserted_new.sh) && bRtorrentRestart=1
Expand Down Expand Up @@ -115,7 +115,7 @@ if [ -f /etc/samba/smb.conf ]; then
fi

#### Cron jobs
if (! grep -q 'rev 0.2' /etc/cron.d/MySB_jobs_check); then
if (! grep -q 'rev 0.3' /etc/cron.d/MySB_jobs_check); then
gfnScriptInvoke 'ScreenSTD' "${MySB_InstallDir}/install/Cron" 'UPGRADE'
fi

Expand Down
43 changes: 25 additions & 18 deletions inc/funcs_by_script/funcs_MySB_CreateUser
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ gfnMinioUsersBuckets() {

case "${sSwitch}" in
'create')
source /etc/MySB/config_db
# source /etc/MySB/config_db
for sBucket in ${!aBucketList[*]}; do
sPolicy="$(echo "${aBucketList[$sBucket]}")"
sPolicy="$(echo "${aBucketList[${sBucket}]}")"
nIdUser="$(cmdMySQL 'MySB_db' "SELECT id_users FROM users WHERE users_ident='${sUser}';")"

sUserValues="$(cmdMySQL 'MySB_db' "SELECT access_key,secret_key FROM minio WHERE id_users='${nIdUser}';" | sed 's/\t/|/g;')"
Expand Down Expand Up @@ -74,24 +74,29 @@ gfnMinioUsersBuckets() {

if [ -n "${sSecretKey}" ] && [ -n "${sPolicy}" ]; then
# Create a new user
mc admin user add mysb "${sUser}" "${sSecretKey}"
mc admin policy set mysb "${sPolicy}" user="${sUser}"
mc config host add "mysb-${sUser}" https://${gsHostNameFqdn}:9000 "${sUser}" "${sSecretKey}" --api s3v4
mc admin user add mysb "${sAccessKey}" "${sSecretKey}"
mc admin policy set mysb "${sPolicy}" user="${sAccessKey}"
# mc config host add "mysb-${sUser}" https://${gsHostNameFqdn}:9000 "${sAccessKey}" "${sSecretKey}" --api s3v4
fi

# Group
mc admin group add mysb MySB_users "${sUser}"
mc admin policy set mysb getonly group=MySB_users
mc admin group add mysb MySB_users "${sAccessKey}"
# mc admin policy set mysb getonly group=MySB_users

# Unset
unset MySQL_RootPassword MySQL_MysbPassword MySQL_BackupManager MySQL_TorrentPassword MySQL_Secret
done
rm -f /tmp/getonly.json
;;
'delete')
# rtorrent/complete
mc admin user remove "${sUser}_complete" "${sUser}"
[ -h "/home/minio/data/${sUser}_complete" ] && rm "/home/minio/data/${sUser}_complete"
for sBucket in ${!aBucketList[*]}; do
nIdUser="$(cmdMySQL 'MySB_db' "SELECT id_users FROM users WHERE users_ident='${sUser}';")"
sUserValues="$(cmdMySQL 'MySB_db' "SELECT access_key,secret_key FROM minio WHERE id_users='${nIdUser}';" | sed 's/\t/|/g;')"
sAccessKey="$(echo "${sUserValues}" | awk '{split($0,a,"|"); print a[1]}')"
sSecretKey="$(echo "${sUserValues}" | awk '{split($0,a,"|"); print a[2]}')"
mc admin user remove mysb "${sAccessKey}"
[ -h "/home/minio/data/${sUser}-${sBucket}" ] && rm "/home/minio/data/${sUser}-${sBucket}"
done
;;
esac
}
Expand Down Expand Up @@ -614,6 +619,8 @@ gfnCreateRtorrentConfigFile() {
install -o "${sUser}" -g MySB_users -m 0755 -d "${sHomeDir}/rtorrent/complete/${sSubDirectory}/"
install -o "${sUser}" -g MySB_users -m 0775 -d "${sHomeDir}/rtorrent/watch/${sSubDirectory}/"
install -o "${sUser}" -g MySB_users -m 0755 -d "${sHomeDir}/rtorrent/torrents/${sSubDirectory}/"
echo "FORCE WATCH SYNC WITH SMARTPHONE CLIENT" >"${sHomeDir}/rtorrent/watch/${sSubDirectory}/.gitkeep"
chown www-data:www-data "${sHomeDir}/rtorrent/watch/${sSubDirectory}/.gitkeep"

if [ -d "${sHomeDir}/rtorrent/complete/${sSubDirectory}/" ]; then
nCountFiles="$(find "${sHomeDir}/rtorrent/complete/${sSubDirectory}/" -maxdepth 1 -mindepth 1 | wc -l)"
Expand All @@ -626,9 +633,9 @@ gfnCreateRtorrentConfigFile() {
fi
fi

case "$bCanBeDeleted" in
case "${bCanBeDeleted}" in
1) # New directory OR maybe to delete
case "$bToDelete" in
case "${bToDelete}" in
1)
rm -rf "${sHomeDir}/rtorrent/complete/${sSubDirectory}/"
rm -rf "${sHomeDir}/rtorrent/watch/${sSubDirectory}/"
Expand Down Expand Up @@ -689,8 +696,8 @@ gfnCreateRtorrentConfigFile() {
perl -pi -e "s/<local_address>/${gsSrvIpAddress}/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<username>/${sUser}/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<homedir>/\/home\/${sUser}/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<scgi_port>/$nPortSCGI/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<port_range>/$nPortRtorrent-$nPortRtorrent/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<scgi_port>/${nPortSCGI}/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/<port_range>/${nPortRtorrent}-${nPortRtorrent}/g" "${sHomeDir}"/.rtorrent.rc
if [ "${gsMySB_PeerBlock}" == "rTorrent" ]; then
perl -pi -e "s/#{1}ipv4_filter.load/ipv4_filter.load/g" "${sHomeDir}"/.rtorrent.rc
perl -pi -e "s/#{1}print/print/g" "${sHomeDir}"/.rtorrent.rc
Expand Down Expand Up @@ -950,7 +957,7 @@ gfnMonthlyPayment() {
;;
esac

if [ $nUpdateCurrentPeriodPrice -eq 1 ]; then
if [ ${nUpdateCurrentPeriodPrice} -eq 1 ]; then
# 1/ Clôture du mois précédent OU d'une période suite à l'ajout d'un user dans:
# - modification de 'tracking_rent_history' en modifiant le champs 'end_of_use' à la date du jour
# ==> Utilisation d'un trigger sur UPDATE pour calculer le prix de la période
Expand All @@ -961,20 +968,20 @@ gfnMonthlyPayment() {
fi
fi

if [ $nNewMonth -eq 1 ]; then
if [ ${nNewMonth} -eq 1 ]; then
# 2/ Ajout du nouveau mois:
cmdMySQL 'MySB_db' "INSERT INTO tracking_rent_status (id_users) VALUES ('${nIdUser}');"
fi

if [ $nCreateNewPeriodPrice -eq 1 ]; then
if [ ${nCreateNewPeriodPrice} -eq 1 ]; then
# 3/ Ajout d'une nouvelle période prix (nouveau mois OU changement du nombre d'utilisateur)
cmdMySQL 'MySB_db' "INSERT INTO tracking_rent_history (id_users,monthly_price,nb_users,start_of_use,end_of_use) VALUES ('${nIdUser}','$gsRentingCostTva','$gnTotalUsers','$dStartOfUse','$dEndOfUse');"
if [ "${nIdUser}" == "${gnMainUserId}" ]; then
cmdMySQL 'MySB_db' "UPDATE tracking_rent_status SET already_payed='9999.99' WHERE id_users='${nIdUser}' AND year='$dYear' AND month='$dMonth';"
fi
fi

if [ $nSendMail -eq 1 ]; then
if [ ${nSendMail} -eq 1 ]; then
# Send email for all users
gfnSendMail "$sMailSubject" "${SeedboxUser}" "$sCase" "${sMessage}"
fi
Expand Down
3 changes: 2 additions & 1 deletion install/Cron
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# rev 0.2
# rev 0.3
# ----------------------------------
# shellcheck source=inc/includes_before
source "$(dirname "$0")"/../inc/includes_before
Expand Down Expand Up @@ -68,6 +68,7 @@ case "${1}" in
# DNScrypt-proxy
if gfnCheckCommand 0 dnscrypt-proxy; then
echo "*/5 * * * * systemctl status dnscrypt-proxy >/dev/null || systemctl restart dnscrypt-proxy" | tee -a /tmp/crontab.tmp
echo "1 12 * * * systemctl restart dnscrypt-proxy" | tee -a /tmp/crontab.tmp
fi
# Plex Media Server
if gfnCheckCommand 0 plexmediaserver; then
Expand Down
2 changes: 1 addition & 1 deletion templates/rtorrent/etc.init.d.rtorrent.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# rev 0.8
# rev 0.9
# ----------------------------------
# __/\\\\____________/\\\\___________________/\\\\\\\\\\\____/\\\\\\\\\\\\\___
# _\/\\\\\\________/\\\\\\_________________/\\\/////////\\\_\/\\\/////////\\\_
Expand Down

0 comments on commit 0fa05f0

Please sign in to comment.