Tag: bash

  • Share Environment Variables in GNU Make

    I think writing up a cheat sheet for GNU Make and environment variables before Christmas is a good idea, right? In GNU Make, by default a single line runs in its own shell. ie. We can use backslash to fake multi-line like this: With .ONESHELL directive multiple lines in one target run in a same […]

  • Update GCP IAM Adaptively with Terraform DataSources

    In a scenario where a service account in a central GCP project needs to be accessible by a group of GKE service accounts across multiple GCP projects, the IAM part in Terraform HCL could look like I can make a variable for the members so it becomes But still the project_ids variable needs to be […]

  • Use fzf to Supercharge Your kubectl Command

    First let’s have a look at fzf, a super fast command line fuzzy finder. It’s mostly written in golang and there are so many ways to use it. In this note, I’ll just use it to select a value from a list in a terminal and then return it to next command. When working with […]

  • Use FZF to Speed Up KUBECTL

    FZF is general purpose option selector for Linux command line. By default fzf is an super-upgrade for the ctrl-r command history finder, but it is helpful for almost any scenario where you need to pick 1 item from a list. Here’s a tiny use case where I use fzf to select a kubernetes namespace and […]

  • 一起疑点重重的案子告破

    今天一早就遇上个难题: 某客户系统无法发送邮件了. 同事追踪了一下日志, 发现是邮件模板渲染程序无权限写某附件的临时文件. 但奇怪的是此文件就是渲染程序自己生成的, 通常能生成文件自然也可以改写. 进一步调查后, 我发现出问题的文件夹是个 NFS 共享文件夹, 而 NFS 服务器端设置了 all_squash, 这解释了文件生成后所有者被更换的原因. 另外一个问题就文件属性, 因为 all_squash 是一直生效的, 所以不可能是问题的直接原因. 文件属性是 rwr-r-, 因此被更换了所有权后原用户就无法再更改了. 而新文件的属性是由 umask 控制的. 再查看一下 umask, 果然, 应该是 002, 看到的却是 022. 这就导致生成的文件属性是 rwr-r- 而不是期待的 rwrwr-. 那么下一步是修改 umask, 但涉及到是将”umask 002″ 放到 .bash_profile 还是 .bashrc 的问题. 原来 .bash_profile 是在登录时生效一次, 而 .bashrc 则是在每个 bash 会话开启时生效. 也就是说, […]