OpenGnsys
OpenGnsys copied to clipboard
Añadir comillas dobles a las variables para prevenir globbing y dividir palabras
Sería añadir comillas a las variables: $variable --> "$variable" Esta es la explicación de esto: https://github.com/koalaman/shellcheck/wiki/SC2086 Adjunto archivo corregido
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L25 PROG="$(basename "$0")"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L67 "$options"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L98 "$MYCNF"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L110 "$LOG_FILE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L111
echo "$DATETIME;$SSH_CLIENT;$1" >> "$LOG_FILE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L118
echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> "$LOG_FILE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L135
cat << EOT > "$MYCNF"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L164
OLDVERSION="$(echo "${file%.*}" | cut -f3 -d-)"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L177
if [ -n "$FILES" -o "$OLDVERSION" = "$NEWVERSION" ] && [ -r "$file" ]; then
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L183
mysql --defaults-extra-file="$MYCNF" -e "CREATE DATABASE $AUXCATALOG"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L185
mysql --defaults-extra-file="$MYCNF" -D "$AUXCATALOG" < $MYSQLFILE &>/dev/null
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L189
importSqlFile $DBDIR/"$file"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L189
mysqldump --defaults-extra-file="$MYCNF" --opt $AUXCATALOG > $MYSQLFILE
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L196 mysql --defaults-extra-file="$MYCNF" -e "DROP DATABASE $AUXCATALOG"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L209
if [ ! -r "$sqlfile" ]; then https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L216
mysql --defaults-extra-file="$MYCNF" --default-character-set=utf8 -D "$AUXCATALOG" < "$sqlfile" https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L259 echo "$CONFIG" | jq -r '.[] as $f | $f.comment + ": " + (if $f.detected then "OK" else "FAIL" end)' | column -ts:
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L275 if ! [ -r "$BACKUPFILE" ]; then
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L276
echo "$PROG: ERROR: Sin acceso al fichero de backup." | tee -a "$FILESAL"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L282
echo "$PROG: ERROR: Sin acceso a la configuración de OpenGnsys." | tee -a "$FILESAL"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L294 checkArchive "$BACKUPFILE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L302
tar -xvzf "$BACKUPFILE" --directory /tmp $TARPARAMS &>/dev/null
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L316
if [ "$OLDVERSION" != "$NEWVERSION" ] ; then
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L339
if [ ! -r "$MYCNF" ]; then
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L340
chmod 600 "$MYCNF"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L342 cat << EOT > "$MYCNF" https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L373 mysqldump --defaults-extra-file="$MYCNF" --opt $CATALOG > "$MYSQLBCK"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L374
chmod 400 "$MYSQLBCK"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L376
mysql --defaults-extra-file="$MYCNF" -D "$CATALOG" < $MYSQLFILE &>/dev/null
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L382
mv /etc/default/opengnsys /etc/default/opengnsys-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L395 mv $DHCPCFGDIR/dhcpd.conf $DHCPCFGDIR/dhcpd.conf-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L397 sed "${BEFOREHOST}"q $DHCPCFGDIR/dhcpd.conf-LAST > $DHCPCFGDIR/dhcpd.conf
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L407 mkdir -p $OPENGNSYS/tftpboot/$BOOTLOADER-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L408 mv $OPENGNSYS/tftpboot/$BOOTLOADER/{01-*,templates,examples} $OPENGNSYS/tftpboot/$BOOTLOADER-"$DATE" 2>/dev/null
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L421 mysql --defaults-extra-file="$MYCNF" -D "$CATALOG" -e "update ordenadores set arranque='10' where arranque='01';" &>/dev/null
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L427 mv $OPENGNSYS/client/etc/engine.cfg $OPENGNSYS/client/etc/engine.cfg-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L432
mv $OPENGNSYS/www/menus $OPENGNSYS/www/menus-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L438 mkdir -p $OPENGNSYS/client/scripts/Custom-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L439 mv $OPENGNSYS/client/scripts/*Custom $OPENGNSYS/client/scripts/Custom-"$DATE"
https://github.com/opengnsys/OpenGnsys/blob/69fd9c1714660848714351e95a7f28aee115c723/installer/opengnsys_import.sh#L450
mv $OPENGNSYS/etc/ogliveinfo.json $OPENGNSYS/etc/ogliveinfo.json-"$DATE"
Un saludo, simplemente le he pasado el shellcheck