Solved the error - Syntax error end of file unexpected (expecting then)

8/01/2022 0 Comments

While running your (Bash) Shell Script have you seen the below error? 

Syntax error: end of file unexpected (expecting "then")

You may think that you have written your Bash script perfectly fine but the below error makes you wonder where the error actually is? This happens when the file is edited in Windows and the editor does not have an option to save files in "Unix" file format. The shell is seeing the word then^M with a carriage return on the end.

Here is the fix for it. From the prompt execute the following command:

sed -i 's/\r$//' filename where filename is the name of your bash script file.

This will ensure that the line ending is proper and executing your file with the sh command will execute your Bash script perfectly well. 

Enjoy shell scripting!!!



0 comments:

Install Grafana v9.0.5 in IBM zLinux (s390x)

8/01/2022 0 Comments

The following article contains the steps that must be followed to install Grafana v9.0.5 from source code on IBM zLinux (s390x).

Pre-requisites for Grafana install

The following software must be installed in a zLinux (s390x) machine. The working folder in this article is assumed to be: grafana-install.

            a. NodeJS version: v16.15.1. (Ensure you execute: export NODE_OPTIONS=--max-old-space-size=12228)

            b. Yarn: v4.0.0-rc.12 (Execute from grafana-install directory: sudo yarn set version 4.0.0-rc.12). This version of yarn contains an important fix related to running Yarn (berry) in Bigendian systems such as zLinux. (More info...)

            c. Go: go version go1.17.11 linux/s390x. Ensure the environment variables for Go (GOPATH and GOROOT) are set:

        d. make: GNU Make 4.3 

Configuration

        1. Download the latest Grafana Source into 'grafana-install' directory using:

                sudo wget https://github.com/grafana/grafana/archive/refs/tags/v9.0.5.tar.gz

       2. Now extract it using: sudo tar -C . -xzf v9.0.5.tar.gz

      The above step will extract Grafana v9.0.5 to directory named: grafana-9.0.5

2. Edit the file grafana-install/grafana-9.0.5/.yarnrc.yml and do the following changes:

            a. Point the yarnPath to ../.yarn/releases/yarn-4.0.0-rc.12.cjs

            b. From the plugins section remove the following entries:

                    -   path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs

                        spec: "@yarnpkg/plugin-typescript"

                    -  path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

                       spec: "@yarnpkg/plugin-interactive-tools"

3. Open grafana-install/grafana-9.0.5/package.json and 

            - change package manager entry as: "packageManager": yarn@4.0.0-rc.12

            under the scripts section change: 

                  "postinstall""husky install" to 

                  "prepare""husky install" 

            - from the devDependencies section, remove all the @swc entries such as:

                    "@swc/core": "1.2.187", 

                    "@swc/helpers": "0.3.13"

4. Remove all occurrences of @swc/helpers from the following files:

        - packages/grafana-data/package.json

        - packages/grafana-schema/package.json

        - packages/grafana-ui/package.json

5. Remove the ts-node section shown below from: scripts/cli/tsconfig.json

        "ts-node": {

            "transpileOnly": true,

            "transpiler": "ts-node/transpilers/swc-experimental"

          }

6. Remove source map generation from webpack for development environment. For this open the file: scripts/webpack/webpack.dev.js and remove the entry devtool: 'inline-source-map'. Please note that there are still issues around the building Grafana v9.0.5 for production (yarn build), hence this article will focus on the dev build only. 


Install the server and client 

With your current directory as grafana-install verify that the yarn version is yarn-4.0.0-rc.12 with the command: yarn -v. (If not execute: sudo yarn set version 4.0.0-rc.12)

1. Change directory to ./grafana-9.0.5 and execute: make run. This will install the server portion of Grafana with all Go libraries/dependencies. Once this completes it goes into a wait state. Press Cntrl + C and exit.

2. Next step is to install the client dependencies. So execute: sudo yarn install 

3. Once client dependencies are installed execute: sudo yarn start. Once it succeeds press Cntrl + C to exit.

4. Now we are all ready to start Grafana. For this navigate to the ./bin directory and start the executable titled: grafana-server. Once it starts at port 3000, open a new browser window and navigate to http://<server_name>:3000

5. Happy visualizations with Grafana!!!


0 comments:

Blog Archive