Both sides previous revisionPrevious revisionNext revision | Previous revision |
howtos:hardware:arm:slackwarearm_local-mirror-repository [2021/03/14 23:08 (UTC)] – [Automated daily logrotate] revised text exaga | howtos:hardware:arm:slackwarearm_local-mirror-repository [2021/04/02 19:22 (UTC)] (current) – [local-slackwarearm-repo.sh script code] revised script header info exaga |
---|
<!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> | <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> |
====== Slackware ARM local mirror repository - SAREPO ====== | ====== Slackware ARM local mirror repository - SAREPO ====== |
| |
| It is acknowledged that there are more complete and distinguished Slackware repository solutions readily available. Such as, alienBOB's [[http://slackware.uk/people/alien/tools/|gen_repos_files.sh]] and [[http://http://slackware.uk/people/alien/tools/|mirror-slackware-current.sh]] scripts, and Dave Spencer's [[http://https://idlemoor.github.io/slackrepo/|slackrepo]]. These are renowned, highly automated, tools for managing Slackware package repositories and mirrors. |
| |
===== Preface ===== | ===== Preface ===== |
| |
It is acknowledged that there are more complete and distinguished Slackware repository solutions readily available. Such as, alienBOB's [[http://slackware.uk/people/alien/tools/|gen_repos_files.sh]] and [[http://http://slackware.uk/people/alien/tools/|mirror-slackware-current.sh]] scripts, and Dave Spencer's [[http://https://idlemoor.github.io/slackrepo/|slackrepo]]. These are renowned, highly automated, tools for managing Slackware package repositories and mirrors. The script featured here does not attempt to supplant or undermine these (or other) contemporary efforts, by //re-inventing the wheel//, so to speak. It's just a much less sophisticated method of achieving the same results, and very much **Slackware ARM specific**. | The script featured here, 'local-slackwarearm-repo.sh' [nickname: 'SAREPO'] does not attempt to supplant or undermine the above (or other) contemporary efforts, by //re-inventing the wheel//, so to speak. It's just a much less sophisticated method of achieving the same results, and very much **Slackware ARM specific**. |
| |
When I was looking into creating a local Slackware ARM mirror, most of the currently available scripts and software to perform this task was just way too advanced and extensive for my needs with regards to Slackware "//repodemia//". Something much more basic and bespoke was preferable, and that's the main reason why this script was created. | When I was looking into creating a local Slackware ARM mirror, most of the currently available scripts and software to perform this task was just way too advanced and extensive for my needs with regards to Slackware "//repodemia//". Something much more basic and bespoke was preferable, and that's the main reason why this script was created. |
| |
| |
===== Question & Answer ===== | ===== Question & Answer ===== |
* A computer system running Slackware - bearing in mind that this 'local-slackwarearm-repo.sh' script is designed to deal only with Slackware ARM files. \\ | * A computer system running Slackware - bearing in mind that this 'local-slackwarearm-repo.sh' script is designed to deal only with Slackware ARM files. \\ |
* Enough free storage space on which to keep the mirror repository files - prior calculations are advised if your intended storage space capacity is sparse. | * Enough free storage space on which to keep the mirror repository files - prior calculations are advised if your intended storage space capacity is sparse. |
* __ONLY__ edit the values specified in the "## local-slackwarearm-repo.sh SETTINGS ##" section - unless you know what you're doing - or else things might break! | * __ONLY__ edit the values specified in the "## local-slackwarearm-repo.sh SETTINGS ##" section of the script code - unless you know what you're doing - or else things might break! |
| |
===== local-slackwarearm-repo.sh script code ===== | ===== local-slackwarearm-repo.sh script code ===== |
# Create Slackware ARM local repository mirror utility script. | # Create Slackware ARM local repository mirror utility script. |
# | # |
# local-slackwarearm-repo.sh - SAREPO [v2.0.3] | # local-slackwarearm-repo.sh - SAREPO [v2.0.3] - 13 Mar 2021 |
# | # |
# Exaga - exaga@fatdog.eu - SARPi Project - 13 Mar 2021 | # Copyright (c) 2021 Exaga - SARPi Project - sarpi.penthux.net |
# | # |
# Version - 08 Mar 2021 [v0.1a] - progenitor | # Version - 08 Mar 2021 [v0.1a] - progenitor |
cd "${SOURCEDIR}" | cd "${SOURCEDIR}" |
echo "${PETNAM} : verifying ${PRGNAM}.database ..." | echo "${PETNAM} : verifying ${PRGNAM}.database ..." |
find . -type f ! -name "index.html" -exec ls -la --time-style=full "{}" >> "${TMP_DATA_DB}" \; | find . -type f ! -name "index.html" -print0 | xargs -0 ls -la --time-style=full >> "${TMP_DATA_DB}" |
if cmp -s "${TMP_DATA_DB}" "${LOCAL_SAREPO_DB}" ; then | cmp -s "${TMP_DATA_DB}" "${LOCAL_SAREPO_DB}" && CMPSTATUS=0 || CMPSTATUS=1 |
log "${PETNAM} : Local repository database is up-to-date ... " | if [[ $CMPSTATUS -eq 0 ]]; then |
| log "${PETNAM} : Local repository database is up-to-date ..." |
else | else |
rm -f "${LOCAL_SAREPO_DB}" && mv "${TMP_DATA_DB}" "${LOCAL_SAREPO_DB}" && log "${PETNAM} : [!] Local repository database updated!" | rm -f "${LOCAL_SAREPO_DB}" && mv "${TMP_DATA_DB}" "${LOCAL_SAREPO_DB}" && log "${PETNAM} : [!] Local repository database updated!" |
fi | fi |
log "${PETNAM} : local repository audit complete" | log "${PETNAM} : local repository audit complete" |
log "+-----------------------------------------------+" | log "+-----------------------------------------------+" && echo >> ${LOG_FILE} |
echo "${PETNAM} update complete" | echo "${PETNAM} update complete" |
# Done | # Done |
Incidentally, for those who don't have any understanding of the terminology involved, "//rotate//" in this case is just another way of saying, "//copy a currently generated log file to another filename and/or location (while compressing it [optional]) and create a new log file in its place//". | Incidentally, for those who don't have any understanding of the terminology involved, "//rotate//" in this case is just another way of saying, "//copy a currently generated log file to another filename and/or location (while compressing it [optional]) and create a new log file in its place//". |
| |
So, by default settings, the 'local-slackwarearm-repo.log' file is located in '/home/<username>/bin/local-slackwarearm-repo.log' and that's what 'logrotate' will be configured to process here. First we need to make a few decisions about where to store the rotated log files, how often to rotate the log(s) and such. The best thing for our purposes is to create a new '/home<username/logs' directory for this purpose. We'll do this as a normal user like this... | So, by default settings, the 'local-slackwarearm-repo.log' file is located in '/home/<username>/bin/local-slackwarearm-repo.log' and that's what 'logrotate' will be configured to process here. First you need to make a few decisions about where to store the rotated log files, how often to rotate the log(s) and such. The easiest thing to do is to create a new '/home<username/logs' directory for this purpose. We'll do this as a normal user like this... |
| |
<code> | <code> |
| |
Some things to note include: \\ | Some things to note include: \\ |
'**<username>**' = the username under which the 'local-slackwarearm-repo.log' file is owned. \\ | '**<username>**' = the username who owns the 'local-slackwarearm-repo.log' file. \\ |
'**su <username> users**' = rotate log files under '<username>' 'group' permissions instead of 'root'. \\ | '**su <username> users**' = rotate log files under '<username>' 'group' permissions instead of 'root'. \\ |
'**olddir**' = the location [PATH] of the directory where any rotated logs will reside. \\ | '**olddir**' = the location [PATH] of the directory where any rotated logs will reside. \\ |
'**compressoptions**', '**compressext**' = compress the file using max '-9' compression, giving it an '.xz' extension. \\ | '**compressoptions**', '**compressext**' = compress the file using max '-9' compression, giving it an '.xz' extension. \\ |
'**create 644 <username> users**' = create a NEW log file in place of the rotated file under '<username>' 'group' permissions. | '**create 644 <username> users**' = create a NEW log file in place of the rotated file under '<username>' 'group' permissions. |
| |
| Things to do or avoid: \\ |
| __DO__ read the '**man logrotate**' page to gain some understanding of the different settings and parameters - https://linux.die.net/man/8/logrotate \\ |
| __DON'T__ set an '**olddir**' PATH (where applicable) if the '**<username>**' does not have access or else 'logrotate' will fail-error. \\ |
| |
| |
Save and exit the file once you are happy with the configuration settings within. | Save and exit the file once you are happy with the configuration settings within. |