def set_perms(tarinfo):
    """
    Set permissions for a file going into a tar
    :param tarinfo: the tarinfo for the file
    :return: the modified tarinfo object
    """
    if tarinfo.isfile():
        if tarinfo.name.endswith('.sh'):
            mode = '774'
        else:
            mode = '664'
    else:
        mode = '775'

    tarinfo.mode = int(mode, 8)  # octal to decimal

    return tarinfo