-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New] Snap arm support #6842
Merged
Merged
[New] Snap arm support #6842
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5b86aa5
Include minimum version of snapd
geekgonecrazy 91789f5
Add in support for arm builds
geekgonecrazy 85f677b
set execute bit on prepare scripts
geekgonecrazy b951542
Add mongo restore, do organize and mongo command
geekgonecrazy e17c4bd
Add README from other repo
geekgonecrazy f5f1448
Add restoredb command
geekgonecrazy a91b744
Update restoredb
geekgonecrazy 333f45a
Add plugs to new commands so they can actually communicate over the n…
geekgonecrazy 9e04864
Merge branch 'snap-fixes' of https://github.com/RocketChat/Rocket.Cha…
geekgonecrazy 89c0180
remove hardcoded version
geekgonecrazy 9d0b261
move usr/bin in arm prepare to bin
geekgonecrazy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
![Rocket.Chat logo](https://rocket.chat/images/logo/logo-dark.svg?v3) | ||
|
||
# rocketchat-server snap for Ubuntu Core (all arch) | ||
|
||
Features: | ||
* bundles ubuntu distribution specific and RC compatible mongodb version | ||
* oplog tailing for mongo by default | ||
* mongodb backup command | ||
* mongodb restore command | ||
* caddy reverse proxy built-in - capable of handling free lestencrypt ssl | ||
|
||
Note: | ||
|
||
Currently, this repository is mirrored on launchpad, and used to build latest ARMHF and i386 snaps. | ||
|
||
You can download recent builds here: | ||
https://code.launchpad.net/~sing-li/+snap/rocketchat-server | ||
|
||
Due an issue with the existing installed base of amd64 users (existing snap always installed mongodb 3.2 [#issue](https://github.com/RocketChat/rocketchat-server-snap/issues/3)), this snap is not currently used for amd64 builds. | ||
|
||
### Test installation | ||
|
||
Download the latest snap file of the corresponding architecture to your Ubuntu Core 16 or 16.04LTS server. | ||
|
||
`sudo snap install ./rocketchat-server-xxxxxxxx.snap --dangerous` | ||
|
||
|
||
### Development or compile your own snap | ||
|
||
Make sure you have `snapcraft` installed. | ||
|
||
``` | ||
git clone https://github.com/RocketChat/rocketchat-server-snap | ||
cd rocketchat-server-snap | ||
snapcraft snap | ||
``` | ||
|
||
### Regression tests (run for amd64, i386 and armhf): | ||
- snapcraft runs properly | ||
- snap installs properly | ||
- all services start automatically | ||
- rc service shows a 5-second restart delay while waiting for mongo | ||
- to test manually, stop rc, stop mongo, start rc, wait 20s or so, start mongo | ||
- rc can be successfully restarted via the "Restart the server" button under Admin > Settings > General | ||
- rc service shows a 5-second delay when restarted via this button | ||
- all commands execute successfully: | ||
- initcaddy | ||
- modify the Caddyfile to test: | ||
- self-signed TLS certificate (use the "tls self_signed" caddy directive) | ||
- changing ports (with and without TLS) | ||
- using IP address (only works without TLS) | ||
- successfully acquiring a Let's Encrypt certificate (requires a registered domain) | ||
- backupdb | ||
- should run only with sudo | ||
- restoredb | ||
- ideally, stop rc service prior to running this (mongo must be running) | ||
- should run only with sudo | ||
- use any file outside of $snap_common (should fail) | ||
- use the file created with backupdb | ||
- use a dummy .tgz file without actual data | ||
- with and without a "parties" directory in the archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/bash | ||
|
||
caddy_bin="caddy" | ||
caddy_dl_ext=".tar.gz" | ||
|
||
# NOTE: `uname -m` is more accurate and universal than `arch` | ||
# See https://en.wikipedia.org/wiki/Uname | ||
unamem="$(uname -m)" | ||
if [[ $unamem == *aarch64* ]]; then | ||
caddy_arch="arm64" | ||
elif [[ $unamem == *64* ]]; then | ||
caddy_arch="amd64" | ||
elif [[ $unamem == *86* ]]; then | ||
caddy_arch="386" | ||
elif [[ $unamem == *armv5* ]]; then | ||
caddy_arch="arm" | ||
caddy_arm="5" | ||
elif [[ $unamem == *armv6l* ]]; then | ||
caddy_arch="arm" | ||
caddy_arm="6" | ||
elif [[ $unamem == *armv7l* ]]; then | ||
caddy_arch="arm" | ||
caddy_arm="7" | ||
else | ||
echo "Aborted, unsupported or unknown architecture: $unamem" | ||
return 2 | ||
fi | ||
|
||
echo "Downloading Caddy for $caddy_os/$caddy_arch$caddy_arm..." | ||
caddy_file="caddy_linux_$caddy_arch${caddy_arm}_custom$caddy_dl_ext" | ||
caddy_url="https://caddyserver.com/download/linux/$caddy_arch$caddy_arm?plugins=$caddy_plugins" | ||
echo "$caddy_url" | ||
|
||
wget --quiet "$caddy_url" -O "$caddy_file" | ||
tar -xzf $caddy_file -C . "$caddy_bin" | ||
chmod +x $caddy_bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash | ||
|
||
if [[ $(uname -m) == "x86_64" ]] | ||
then | ||
wget --backups=0 "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.2.7.tgz" | ||
tar -zxf ./mongodb-linux-x86_64-ubuntu1604-3.2.7.tgz --strip-components=1 | ||
else | ||
IFS=" " read -a links <<< $(apt-get -y --print-uris install mongodb | egrep -o "https?://[^']+") | ||
for link in ${links[@]} | ||
do | ||
wget --backups=0 ${link} | ||
done | ||
|
||
IFS=" " read -a deb_pkgs <<< $(ls ./ | egrep "\.deb") | ||
for pkg in ${deb_pkgs[@]} | ||
do | ||
echo "Extracting ${pkg}..." | ||
dpkg-deb -R ${pkg} ./ | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#! /bin/bash | ||
|
||
if [[ ${EUID} != 0 ]] | ||
then | ||
echo "[-] This task must be run with 'sudo'." | ||
exit | ||
fi | ||
|
||
backup_file=${1} | ||
if [[ ! -f ${backup_file} ]] | ||
then | ||
echo "[-] Usage: snap run rocketchat-server.rcrestore ${SNAP_COMMON}/backup_file.tgz" | ||
exit | ||
fi | ||
|
||
cd ${backup_file%/*} | ||
if [[ -z $(pwd | grep "${SNAP_COMMON}") ]] | ||
then | ||
echo "[-] Backup file must be within ${SNAP_COMMON}." | ||
exit | ||
fi | ||
|
||
function ask_backup { | ||
echo -n "\ | ||
*** ATTENTION *** | ||
* Your current database WILL BE DROPPED prior to the restore! | ||
* Would you like to make a backup of the current database before proceeding? | ||
* (y/n/Q)> " | ||
|
||
read choice | ||
[[ "${choice,,}" = n* ]] && return | ||
[[ "${choice,,}" = y* ]] && backupdb.sh && return | ||
exit | ||
} | ||
|
||
function warn { | ||
echo "[!] ${1}" | ||
echo "[*] Check ${restore_dir}/${log_name} for details." | ||
} | ||
|
||
function abort { | ||
echo "[!] ${1}" | ||
echo "[*] Check ${restore_dir}/${log_name} for details." | ||
echo "[-] Restore aborted!" | ||
exit | ||
} | ||
|
||
mongo parties --eval "db.getCollectionNames()" | grep "\[ \]" >> /dev/null || ask_backup | ||
echo "[*] Extracting backup file..." | ||
restore_dir="${SNAP_COMMON}/restore" | ||
log_name="extraction.log" | ||
mkdir -p ${restore_dir} | ||
cd ${restore_dir} | ||
tar --no-same-owner --overwrite -zxvf ${backup_file} &> "${restore_dir}/${log_name}" | ||
[[ $? != 0 ]] && abort "Failed to extract backup files to ${restore_dir}!" | ||
echo "[*] Restoring data..." | ||
data_dir=$(tail "${restore_dir}/${log_name}" | grep parties/. | head -n 1) | ||
[[ -z ${data_dir} ]] && abort "Restore data not found within ${backup_file}! | ||
Please check that your backup file contains the backup data within the \"parties\" directory." | ||
data_dir=$(dirname ${data_dir}) | ||
log_name="mongorestore.log" | ||
mongorestore --db parties --noIndexRestore --drop ${data_dir} &> "${restore_dir}/${log_name}" | ||
[[ $? != 0 ]] && abort "Failed to execute mongorestore from ${data_dir}!" | ||
# If mongorestore.log only has a few lines, it likely didn't find the dump files | ||
log_lines=$(wc -l < "${restore_dir}/${log_name}") | ||
[[ ${log_lines} -lt 24 ]] && warn "Little or no restore data found within ${backup_file}! | ||
Please check that your backup file contains all the backup data within the \"parties\" directory." | ||
echo "[*] Preparing database..." | ||
log_name="mongoprepare.log" | ||
mongo parties --eval "db.repairDatabase()" --verbose &> "${restore_dir}/${log_name}" | ||
[[ $? != 0 ]] && abort "Failed to prepare database for usage!" | ||
echo "[+] Restore completed! Please restart the snap.rocketchat services to verify." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geekgonecrazy seems I overlooked this when I renamed the scripts.
Change:
echo "[-] Usage: snap run rocketchat-server.
rcrestore${SNAP_COMMON}/backup_file.tgz"To:
echo "[-] Usage: snap run rocketchat-server.restoredb ${SNAP_COMMON}/backup_file.tgz"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I missed too! Thanks will change