Skip to content

Commit

Permalink
Merge branch 'develop' into update-meteor-1-7
Browse files Browse the repository at this point in the history
* develop: (27 commits)
  Fix stylelint
  [FIX]  Login error message not obvious if user not activated (#11785)
  [NEW] REST endpoints to get moderators from groups and channels (#11909)
  [NEW] User preference for 24- or 12-hour clock (#11169)
  [FIX] Adding scroll bar to read receipts modal (#11919)
  [FIX] Fixing translation on 'yesterday' word when calling timeAgo function (#11946)
  [FIX] Fixing spacement between tags and words on some labels (#12018)
  [FIX] video message recording, issue #11651 (#12031)
  [FIX] Prevent form submission in Files List search (#11999)
  [NEW] REST endpoint to set groups' announcement (#11905)
  [FIX] Re-add the eye-off icon (#12079)
  [NEW] Livechat trigger option to run only once (#12068)
  [IMPROVE] Use eslint-config package (#12044)
  [FIX] Internal error when cross-origin with CORS is disabled (#11953)
  [FIX] Message reaction in GraphQL API (#11967)
  [FIX] Direct messages leaking into logs (#11863)
  Fix the stylelint (#11991)
  [NEW] REST endpoints to create roles and assign roles to users (#11855)
  [FIX] Hidden admin sidenav on embedded layout (#12025)
  [FIX] Update user information not possible by admin if disabled to users (#11955)
  ...

# Conflicts:
#	package-lock.json
#	package.json
  • Loading branch information
engelgabriel committed Sep 19, 2018
2 parents dd3bb76 + 252eead commit 3cef187
Show file tree
Hide file tree
Showing 103 changed files with 6,250 additions and 3,074 deletions.
137 changes: 1 addition & 136 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,140 +1,5 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017,
"ecmaFeatures": {
"experimentalObjectRestSpread" : true
}
},
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"jquery": true
},
"rules": {
"no-multi-spaces": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-multi-str": 2,
"no-use-before-define": 2,
"no-const-assign": 2,
"no-cond-assign": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-keys": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-duplicate-case": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-func-assign": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-mixed-operators": [2, {
"groups": [
["%", "**"],
["%", "+"],
["%", "-"],
["%", "*"],
["%", "/"],
["**", "+"],
["**", "-"],
["**", "*"],
["**", "/"],
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
],
"allowSamePrecedence": false
}],
"no-mixed-spaces-and-tabs": 2,
"no-sparse-arrays": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-undef": 2,
"no-unreachable": 2,
"no-unused-vars": [2, {
"vars": "all",
"args": "after-used"
}],
"no-void": 2,
"no-var": 2,
"no-multiple-empty-lines": [2, { "max": 2 }],
"no-nested-ternary": 2,
"prefer-rest-params": 2,
"array-callback-return": 2,
"prefer-destructuring": [2, {
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": false,
"object": false
}
}, {
"enforceForRenamedProperties": false
}],
"no-duplicate-imports": 2,
"arrow-parens": [2, "always"],
"quote-props": [2, "as-needed"],
"no-array-constructor": 2,
"arrow-spacing": 2,
"arrow-body-style": [2, "as-needed"],
"no-confusing-arrow": [2, { "allowParens": true }],
"dot-notation": 2,
"no-unneeded-ternary": 2,
"spaced-comment": 2,
"space-infix-ops": 2,
"array-bracket-spacing": [2, "never"],
"object-curly-spacing": [2, "always"],
"one-var": [2, "never"],
"no-lonely-if": 2,
"no-trailing-spaces": 2,
"complexity": [1, 31],
"space-in-parens": [2, "never"],
"space-before-function-paren": [2, "never"],
"space-before-blocks": [2, "always"],
"indent": [2, "tab", {"SwitchCase": 1}],
"eol-last": [2, "always"],
"comma-dangle": [2, "always-multiline"],
"keyword-spacing": 2,
"block-spacing": 2,
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"computed-property-spacing": 2,
"comma-spacing": 2,
"comma-style": 2,
"guard-for-in": 2,
"wrap-iife": 2,
"block-scoped-var": 2,
"curly": [2, "all"],
"eqeqeq": [2, "allow-null"],
"new-cap": [2, {
"capIsNewExceptions": ["Match.Optional", "Match.Maybe", "Match.OneOf", "Match.Where", "Match.ObjectIncluding", "Push.Configure", "SHA256"]
}],
"use-isnan": 2,
"valid-typeof": 2,
"linebreak-style": [2, "unix"],
"prefer-template": 2,
"template-curly-spacing": [2, "always"],
"quotes": [2, "single"],
"semi": [2, "always"],
"prefer-const": 2,
"object-shorthand": 2
},
"extends": ["@rocket.chat/eslint-config"],
"globals": {
"__meteor_runtime_config__" : false,
"AccountBox" : false,
Expand Down
40 changes: 40 additions & 0 deletions .snapcraft/resources/backupdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

if [[ ${EUID} != 0 ]]; then
echo "[-] This task must be run with 'sudo'."
exit 1
fi

if $(ps x | grep "node ${SNAP}/main.js" | grep -qv "grep"); then
echo "[-] Please shutdown Rocket.Chat first to get a clean backup"
echo "[-] Use 'sudo systemctl stop snap.rocketchat-server.rocketchat-server'"
fi

TIMESTAMP=$(date +"%Y%m%d.%H%M")
BACKUP_DIR="${SNAP_COMMON}/backup"

if [[ ! -d ${BACKUP_DIR} ]]; then
mkdir ${BACKUP_DIR}
fi

if [[ -d ${BACKUP_DIR}/dump ]]; then
rm -rf ${BACKUP_DIR}/dump
fi

if [[ -f ${BACKUP_DIR}/rocketchat_backup_${TIMESTAMP}.tar.gz ]]; then
rm -f ${BACKUP_DIR}/rocketchat_backup_${TIMESTAMP}.tar.gz
fi

if [[ -f ${BACKUP_DIR}/backup_${TIMESTAMP}.log ]]; then
rm -f ${BACKUP_DIR}/backup_${TIMESTAMP}.log
fi

echo "[*] Creating backup file..."
mkdir ${BACKUP_DIR}/dump
echo "[*] Dumping database with \"mongodump -d parties -o ${BACKUP_DIR}/dump\"" > "${BACKUP_DIR}/backup_${TIMESTAMP}.log"
mongodump -d parties -o ${BACKUP_DIR}/dump &>> "${BACKUP_DIR}/backup_${TIMESTAMP}.log"
echo "[*] Packing archive with \"tar czvf ${BACKUP_DIR}/rocketchat_backup_${TIMESTAMP}.tar.gz ${BACKUP_DIR}/dump\"" >> "${BACKUP_DIR}/backup_${TIMESTAMP}.log"
tar czvf ${BACKUP_DIR}/rocketchat_backup_${TIMESTAMP}.tar.gz -C ${BACKUP_DIR} dump &>> "${BACKUP_DIR}/backup_${TIMESTAMP}.log"
rm -rf ${BACKUP_DIR}/dump

echo "[+] A backup of your data can be found at ${BACKUP_DIR}/rocketchat_backup_${TIMESTAMP}.tar.gz"
7 changes: 0 additions & 7 deletions .snapcraft/resources/rcbackup

This file was deleted.

132 changes: 74 additions & 58 deletions .snapcraft/resources/restoredb
Original file line number Diff line number Diff line change
@@ -1,72 +1,88 @@
#! /bin/bash
#!/bin/bash

if [[ ${EUID} != 0 ]]
then
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 1
}

if [[ ${EUID} != 0 ]]; then
echo "[-] This task must be run with 'sudo'."
exit
exit 1
fi

backup_file=${1}
if [[ ! -f ${backup_file} ]]
then
echo "[-] Usage: snap run rocketchat-server.restoredb ${SNAP_COMMON}/backup_file.tgz"
exit
echo "*** ATTENTION ***"
echo "* Your current database WILL BE DROPPED prior to the restore!"
echo "* Do you want to continue?"

select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit 1;;
esac
done

if $(ps x | grep "node ${SNAP}/main.js" | grep -qv "grep"); then
echo "[-] Please shutdown Rocket.Chat first to restore a clean backup"
echo "[-] Use 'sudo systemctl stop snap.rocketchat-server.rocketchat-server'"
echo "[-] Backup aborted!"
exit 1
fi

cd ${backup_file%/*}
if [[ -z $(pwd | grep "${SNAP_COMMON}") ]]
then
echo "[-] Backup file must be within ${SNAP_COMMON}."
exit
TIMESTAMP=$(date +"%Y%m%d.%H%M")
RESTORE_DIR="${SNAP_COMMON}/restore"
DATA_DIR="${RESTORE_DIR}/dump/parties"
LOG_NAME="restore_${TIMESTAMP}.log"

if [[ ! -d ${RESTORE_DIR} ]]; then
mkdir ${RESTORE_DIR}
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 && return
exit
}
if [[ -d ${RESTORE_DIR}/dump ]]; then
rm -rf ${RESTORE_DIR}/dump
fi

function warn {
echo "[!] ${1}"
echo "[*] Check ${restore_dir}/${log_name} for details."
}
if [[ -f ${RESTORE_DIR}/${LOG_NAME} ]]; then
rm -f ${RESTORE_DIR}/${LOG_NAME}
fi

function abort {
echo "[!] ${1}"
echo "[*] Check ${restore_dir}/${log_name} for details."
echo "[-] Restore aborted!"
exit
}
BACKUP_FILE=${1}
if [[ ! -f ${BACKUP_FILE} ]]; then
echo "[-] Usage: sudo snap run rocketchat-server.restoredb ${SNAP_COMMON}/rocketchat_backup_{TIMESTAMP}.tar.gz"
exit 1
fi

if ! $(echo "${BACKUP_FILE}" | grep -q "${SNAP_COMMON}"); then
echo "[-] Backup file must be within ${SNAP_COMMON}."
exit 1
fi

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 "[*] Extracting backup file with \"tar --no-same-owner --overwrite -xzvf ${BACKUP_FILE}\"" &> "${RESTORE_DIR}/${LOG_NAME}"
cd ${RESTORE_DIR}
tar --no-same-owner --overwrite -xzvf ${BACKUP_FILE} &>> "${RESTORE_DIR}/${LOG_NAME}" \
|| abort "Failed to extract backup files to ${RESTORE_DIR}!"

if [ $(ls -l ${DATA_DIR} | wc -l) -le 1 ]; then
abort "No restore data found within ${DATA_DIR}!"
fi
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 "[*] Restoring data with \"mongorestore --db parties --noIndexRestore --drop ${DATA_DIR}\"" &>> "${RESTORE_DIR}/${LOG_NAME}"
mongorestore --db parties --noIndexRestore --drop ${DATA_DIR} &>> "${RESTORE_DIR}/${LOG_NAME}" \
|| abort "Failed to execute mongorestore from ${DATA_DIR}!"
if [ $(cat ${RESTORE_DIR}/${LOG_NAME} | grep $(date +%Y) | wc -l) -lt 24 ]; then
warn "Little or no data could be restored from the backup!"
fi

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."
echo "[*] Preparing database with \"mongo parties --eval 'db.repairDatabase()' --verbose\"" &>> "${RESTORE_DIR}/${LOG_NAME}"
mongo parties --eval "db.repairDatabase()" --verbose &>> "${RESTORE_DIR}/${LOG_NAME}" \
|| abort "Failed to prepare database for usage!"

echo "[+] Restore completed! Please with 'sudo systemctl restart snap.rocketchat-server.rocketchat-server' to verify."
6 changes: 3 additions & 3 deletions .snapcraft/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ apps:
command: env LC_ALL=C restoredb
plugs: [network]
backupdb:
command: env LC_ALL=c rcbackup
command: env LC_ALL=C backupdb
plugs: [network]
initcaddy:
command: env LC_ALL=c initcaddy
command: env LC_ALL=C initcaddy
parts:
node:
plugin: dump
Expand Down Expand Up @@ -77,7 +77,7 @@ parts:
plugin: dump
source: resources/
organize:
rcbackup: bin/rcbackup
backupdb: bin/backupdb
restoredb: bin/restoredb
startmongo: bin/startmongo
startRocketChat: bin/startRocketChat
Expand Down
1 change: 0 additions & 1 deletion .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"declaration-colon-space-after": "always-single-line",
"declaration-colon-space-before": "never",
"font-family-no-duplicate-names": true,
"function-calc-no-unspaced-operator": true,
"function-comma-newline-after": "always-multi-line",
"function-comma-space-after": "always-single-line",
"function-comma-space-before": "never",
Expand Down
16 changes: 14 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ if [ "$1" == "development" ]; then
fi

cd $ROOTPATH
curl -fSL "https://s3.amazonaws.com/rocketchatbuild/rocket.chat-develop.tgz" -o rocket.chat.tgz
tar zxf rocket.chat.tgz && rm rocket.chat.tgz
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0E163286C20D07B9787EBE9FD7F9D0414FD08104

curl -SLf "https://releases.rocket.chat/latest/download/" -o rocket.chat.tgz
curl -SLf "https://releases.rocket.chat/latest/asc" -o rocket.chat.tgz.asc \

gpg --verify rocket.chat.tgz.asc
if [ $? -eq 0 ]; then
echo "Verified download integrity"
else
echo "Invalid file, download corrupted or incomplete"
exit 1
fi

tar zxf rocket.chat.tgz && rm rocket.chat.tgz rocket.chat.tgz.asc
cd $ROOTPATH/bundle/programs/server
npm install
pm2 startOrRestart $ROOTPATH/current/$PM2FILE
Loading

0 comments on commit 3cef187

Please sign in to comment.